LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to save output to .csv format?? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-save-output-to-csv-format-4175590067/)

usamaAkhtar 09-24-2016 06:49 AM

how to save output to .csv format??
 
Hi!

since I'm new to linux, I"m finding it really hard to save my output values to .csv format. I hope you guys can help me.

I'm using geany as IDE. I have four analogue inputs to MCP3208 which gives input to my pi, after applying some features my pi returns me a value different for each 4 channels (i-e four values). i am taking 2000 samples. I can see those values in IDE or lxTerminal but i want to save all those values to .csv formatted file so that there is an ease of access.

hope to get a reply soon.
Thanks.

Shadow_7 09-24-2016 06:55 AM

CSV is comma separated values. So...

1 2 3 4

becomes

"1","2","3","4"

You have to reformat the data. AKA programming / scripting 101. Using sed, awk, and a few other things might help simplify the process.

syg00 09-24-2016 07:11 AM

Simplest is probably "tr" - see the manpage, but if (for example) the data are blank separated this might suffice
Code:

tr " " ","  < file.in > file.out

pan64 09-24-2016 09:09 AM

would be nice to see the original lines and the required output. Just to have an idea what do you really need.

IsaacKuo 09-24-2016 09:58 AM

The original poster may be more familiar with Windows powershell, which has an "export-csv" command. Powershell operates on objects/arrays/etc, so it makes sense to have an export-csv feature to export an object array.

*nix operates on streams of bytes, though. It's a fundamentally different paradigm. So in *nix, converting to a csv is a low level string manipulation task that depends on the format of what's going in.

AnanthaP 09-25-2016 06:51 AM

I read somewhere that geany has an export plugin that might be exactly what you want.

ok

usamaAkhtar 09-27-2016 02:59 AM

thanks everyone!!

@pan64 i will provide you the code asap.

thanks again :)


All times are GMT -5. The time now is 02:00 AM.