LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2016, 07:49 AM   #1
usamaAkhtar
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Rep: Reputation: Disabled
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.
 
Old 09-24-2016, 07:55 AM   #2
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,318
Blog Entries: 1

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
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.
 
2 members found this post helpful.
Old 09-24-2016, 08:11 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,832

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
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
 
1 members found this post helpful.
Old 09-24-2016, 10:09 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
would be nice to see the original lines and the required output. Just to have an idea what do you really need.
 
1 members found this post helpful.
Old 09-24-2016, 10:58 AM   #5
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 8 Jessie
Posts: 1,688
Blog Entries: 5

Rep: Reputation: 163Reputation: 163
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.
 
1 members found this post helpful.
Old 09-25-2016, 07:51 AM   #6
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 804

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

ok
 
Old 09-27-2016, 03:59 AM   #7
usamaAkhtar
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
thanks everyone!!

@pan64 i will provide you the code asap.

thanks again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] howto: ls output to csv format limdel Linux - Newbie 12 09-19-2014 02:00 PM
[SOLVED] Shell script output in .csv format mangal023 Linux - Newbie 3 02-24-2014 10:54 PM
Putty using csv files in BASH to format file in script as output smks Linux - Newbie 7 12-22-2011 06:50 PM
How-To format output in CSV to match stdout? Linux_Kidd Programming 7 09-29-2011 04:22 PM
Redirect output in .xls or csv format jeesun Programming 5 12-25-2009 06:56 PM


All times are GMT -5. The time now is 10:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration