Csv file reader

FrameXX

Well-known member
You can get raw data of csv file using shell action and saving output into string.

Bash:
cat /storage/emulated/0/file.csv
 

Dm114

Well-known member
You can get raw data of csv file using shell action and saving output into string.

Bash:
cat /storage/emulated/0/file.csv
I agree with you but to me, with this plain 'cat' command, all lines are concatenated with no LF nor CR. I have to add the '-e' option (cat -e file_name) to generate a $ symbol between every line and then to replace every $ symbol by '\n'. Which is a poor workaround because you can't have any $ symbol in your input file.

Would you have another solution?
 

dsnz

Well-known member
you are right and it seems to be a peculiarity of MD that strips newlines before storing into a variable

I guess we could ask @MacroDroidDev to fix this

however there is another workaround
assume that a character does not exist in your text, eg. ':'
then do

cat file | tr '\n' ':'
action text, replace all : with \n

if it's difficult to find a character that does not exist in your text
then there is another workaround using the sed command to replace newline with a string like EOL or a-dummy-string or whatever you like
 

Dm114

Well-known member
you are right and it seems to be a peculiarity of MD that strips newlines before storing into a variable

I guess we could ask @MacroDroidDev to fix this

however there is another workaround
assume that a character does not exist in your text, eg. ':'
then do

cat file | tr '\n' ':'
action text, replace all : with \n

if it's difficult to find a character that does not exist in your text
then there is another workaround using the sed command to replace newline with a string like EOL or a-dummy-string or whatever you like
Thanks a lot for your suggestion. I'm not familiar at all with shell script so I'm sure it'll help.

What would be the syntax of the 'sed' command (it sound even better that your previous suggestion)?
 

Dm114

Well-known member
it would be

cat file | sed -z 's/\n/EOL/g'
Unfortunately '-z' option doesn't work/doesn't exist.

As every lines of my file begin with the same special character '[' (not supposed to be used elsewhere), I used sed 's/\[/CrLf[/g and then replace 'CrLf[' by'\n[': it works fine as a workaround!
 

dsnz

Well-known member
it's strange !! , -z works for me
perhaps device is old ? or the manufacturer has really killed the original Android code/setup 😂

what device and Android you use ?

good you have a solution

even without -z there are other sed commands that can do the same thing and should work for you though they are more complicated
 

Dm114

Well-known member
it's strange !! , -z works for me
perhaps device is old ? or the manufacturer has really killed the original Android code/setup 😂

what device and Android you use ?

good you have a solution

even without -z there are other sed commands that can do the same thing and should work for you though they are more complicated
Thanks again for your reply.
I was told that my signature appears at the bottom of my messages but it seems not. So, here it is:
Sent from my unrooted ADB hacked Samsung Galaxy A40 • Android v9
MD helper v1.7 • MD v5.23.7 Pro

There is a lot of helpful information in MacroDroid Wiki: go and have a look!
 

dsnz

Well-known member
5.22.6

in a few days it's exactly 2 months without any update
Beta has become the normal..
I will complain loudly .. this is ridiculous
😂
 

Dm114

Well-known member
5.22.6

in a few days it's exactly 2 months without any update
Beta has become the normal..
I will complain loudly .. this is ridiculous
😂
I don't think it's a beta one.
As I am 'Google allergic' I download from either Uptodown or Apkpure... 😉
 

Dm114

Well-known member
you are right and it seems to be a peculiarity of MD that strips newlines before storing into a variable

I guess we could ask @MacroDroidDev to fix this

however there is another workaround
assume that a character does not exist in your text, eg. ':'
then do

cat file | tr '\n' ':'
action text, replace all : with \n

if it's difficult to find a character that does not exist in your text
then there is another workaround using the sed command to replace newline with a string like EOL or a-dummy-string or whatever you like
It's now fixed with the new 5.24.1 version, thanks to @MacroDroidDev. 👍🙏
 
Top