Fair enough!
The goal at the moment is to read a .csv and split it into variables containing the column items. e.g., a .csv which has items:
1,a,!
2,b,@
3,c,#
would output variables in the form %column1 = 1,2,3 %column2 = a,b,c %column 3 = !,@,#. I also account for some items being empty. So a file containing:
3,b
would output %column1 = 1,2,3 %column2 = ,,b and %column3 = !,,
So now how did I do it? Basically:
- Read file in variable %fileinfo
- Split variable %fileinfo. no splitter. This seems to split it based on newlines
- Set variable %lengthoflongestline (to be used find how many items should be in line to the number of columns can be set)
- Loop through each of the array %fileinfo
- Split each item based on comma
- count how many items in the new array
- Compare to %lengthofnewline and renew %lengthofnewline if the count is larger
- Now that I have the number of columns required I loop through each item in %fileinfo()
- Split based on ,
- Loop through each item in the new array
- store each existing item into %columnX etc. where X is set by a counter running through the loop to determine which column we are at (using array push)
- if the number of items is less than %lengthoflongestline then I fill the rest of the spaces with ' '
Thats the basic idea. Thought its easier than writing each Tasker task.
Thanks!