LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Curl command, Json data to excel (https://www.linuxquestions.org/questions/linux-newbie-8/curl-command-json-data-to-excel-4175514246/)

gaa100 08-11-2014 11:14 AM

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

szboardstretcher 08-11-2014 11:16 AM

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.

gaa100 08-11-2014 11:25 AM

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

szboardstretcher 08-13-2014 06:52 AM

Quote:

Originally Posted by gaa100 (Post 5218878)
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.


All times are GMT -5. The time now is 09:12 AM.