LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 08-11-2014, 12:14 PM   #1
gaa100
LQ Newbie
 
Registered: Aug 2014
Posts: 4

Rep: Reputation: Disabled
Curl command, Json data to excel


Hi there,

I'm using the curl command to get data behind a graph on a website.

Code:
curl -k -u 'password' 'http://website&json'
This returns it as a json object in the terminal window which I'm not familiar with.

What I would like to do is to write the data into a text file that I can import into excel etc.

Would anybody be able to advise me how to do this?

Thanks
tom
 
Old 08-11-2014, 12:16 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,783
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
use the -o paramater:

Code:
curl whatever -o output.txt
OR, if you mean convert JSON to CSV for excel,.. then:

Same thing, but also search for 'json to csv' and pick your poison.

Last edited by szboardstretcher; 08-11-2014 at 12:27 PM.
 
Old 08-11-2014, 12:25 PM   #3
gaa100
LQ Newbie
 
Registered: Aug 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for your reply.

Do you mean like from this?

Code:
curl -k -u 'sensor:xxxxx' 'http://172.31.2.43:4243/api/query/?start=2014/08/11-08:02:19&end=2014/08/11-10:00:00&m=avg:SENS_NITROGEN_DIOXIDE%7Bsender_id=bce76eca-b591-11e3-b2f8-984fee001002%7D&json'
to this

Code:
curl -k -u 'sensor:xxxxx' 'http://172.31.2.43:4243/api/query/?start=2014/08/11-08:02:19&end=2014/08/11-10:00:00&m=avg:SENS_NITROGEN_DIOXIDE%7Bsender_id=bce76eca-b591-11e3-b2f8-984fee001002%7D' -o output.txt
Where does the code get saved to?

thanks
 
Old 08-13-2014, 07:52 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,783
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
Quote:
Originally Posted by gaa100 View Post
Thanks for your reply.

Do you mean like from this?

Code:
curl -k -u 'sensor:xxxxx' 'http://172.31.2.43:4243/api/query/?start=2014/08/11-08:02:19&end=2014/08/11-10:00:00&m=avg:SENS_NITROGEN_DIOXIDE%7Bsender_id=bce76eca-b591-11e3-b2f8-984fee001002%7D&json'
to this

Code:
curl -k -u 'sensor:xxxxx' 'http://172.31.2.43:4243/api/query/?start=2014/08/11-08:02:19&end=2014/08/11-10:00:00&m=avg:SENS_NITROGEN_DIOXIDE%7Bsender_id=bce76eca-b591-11e3-b2f8-984fee001002%7D' -o output.txt
Where does the code get saved to?

thanks
Yes. The code is -o "outputted" to output.txt in that case.
 
  


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
Google Places API JSon Data trscookie Programming 1 12-08-2013 04:13 PM
How to copy Arabic data from excel fiel to another excel file in PERL? David the H. Linux - Newbie 0 04-23-2012 10:24 AM
[SOLVED] cURL POST data command from shell returns HTTP Error Code 408 fyndr Linux - Software 3 03-04-2011 10:17 AM
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 12:42 PM


All times are GMT -5. The time now is 03:08 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