Data export to csv

122 views
Skip to first unread message

Janne Prokkola

unread,
Apr 21, 2020, 3:24:43 PM4/21/20
to weewx-user
hello

I'd like to export my database to csv. Is there any easy way to export US format database to metrics units?

I'm building my weather station set up. I'm thinking should I have the database in metrics format or should I stay in US. In Finland I have no use for imperial/US units.

best regards
Janne Prokkola 

Tom Keffer

unread,
Apr 21, 2020, 4:53:12 PM4/21/20
to weewx-user
If you want the results in metric, it would be best to convert the database first, then dump it to CSV. For how to convert the database, see the section Changing the database unit system in the Customizing Guide.

You didn't say what kind of database, but if you use sqlite, the utility sqlite3 can export to CSV. You may need to download it first

sudo apt install sqlite3

Then

sqlite3 weewx.sdb
sqlite> .headers on
sqlite> .mode csv
sqlite> .output weewx.csv
sqlite> select * from archive;

This will create a file weewx.csv with the data. It will be in whatever unit system your database is in. Hence, the need to convert first.



--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/ba6c819d-a9c5-406e-9854-60af09e81b9b%40googlegroups.com.

Janne Prokkola

unread,
Apr 22, 2020, 10:39:06 AM4/22/20
to weewx-user
hello
sorry, I add more info.

I have sqlite. In User's Guide it says:

"Because of this, unless you have a special purpose application, there is really no good reason to change from the default, which is US"

I want to keep the installation as default as possible. But on the other hand if I want to export sqlite as metrics, should we think this is a special purpose enough to start with (or convert to) metrics?

And, if I choose to use metrics in database, will there be any problems in future upgrades like should I always make changes in conf-files after upgrade?

Janne


tiistai 21. huhtikuuta 2020 23.53.12 UTC+3 Tom Keffer kirjoitti:
If you want the results in metric, it would be best to convert the database first, then dump it to CSV. For how to convert the database, see the section Changing the database unit system in the Customizing Guide.

You didn't say what kind of database, but if you use sqlite, the utility sqlite3 can export to CSV. You may need to download it first

sudo apt install sqlite3

Then

sqlite3 weewx.sdb
sqlite> .headers on
sqlite> .mode csv
sqlite> .output weewx.csv
sqlite> select * from archive;

This will create a file weewx.csv with the data. It will be in whatever unit system your database is in. Hence, the need to convert first.



On Tue, Apr 21, 2020 at 12:24 PM Janne Prokkola <jannep...@gmail.com> wrote:
hello

I'd like to export my database to csv. Is there any easy way to export US format database to metrics units?

I'm building my weather station set up. I'm thinking should I have the database in metrics format or should I stay in US. In Finland I have no use for imperial/US units.

best regards
Janne Prokkola 

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx...@googlegroups.com.

Thomas Keffer

unread,
Apr 22, 2020, 10:55:48 AM4/22/20
to weewx-user
If you need to export to CSV only once, then there is no need to convert the database. Just make a copy, convert that, export to CSV, then throw the copy away.

Otherwise, if you expect to do this regularly, then, yes, convert and use the converted database.

There should be no problems with upgrades. Being able to support multiple database systems is a key feature of WeeWX.

-tk

To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/79f911de-a153-4968-9dd7-0e35b4c19ba6%40googlegroups.com.

Jarmo Seppänen

unread,
Apr 22, 2020, 11:45:43 AM4/22/20
to weewx-user
Consider if you want to change to metricwx rather than metric. The docs have a good description of the differences.

Janne Prokkola

unread,
Apr 23, 2020, 1:14:54 PM4/23/20
to weewx-user
Thank you both Thomas and Jarmo for your help.

metricwx is my choice.

Janne
Reply all
Reply to author
Forward
0 new messages