[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading Files with mixed text and numbers

From: Fritz Sonnichsen
Subject: Re: Loading Files with mixed text and numbers
Date: Wed, 12 Jul 2017 12:51:20 -0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

Yes-unfortunately dates are always a problem with many languages. I really got messed up with a  system in PERL a while back-had to account for leap seconds and other annoying facts due to the earths rotation (can't someone change that!)

Thanks for the comments-I am sure I will need them eventually.

On 7/10/2017 11:15 AM, Przemek Klosowski wrote:
On 07/09/2017 06:53 PM, siko1056 wrote:
Fritz Sonnichsen wrote
I did this all the time with Matlab--loaded files with the very common 
form of records like this:
2017/07/07,   13:59:59,   022.2,   12.69

Personally, I found that it's a little awkward to process dates in Octave, so I like to keep my time series data in sqlite because it has a builtin CSV import, and does dates very well. The purist may object to such mixing, but the practical person would point out that the Domain Specific Languages (DSL) concept is a cool idea.

For Octave use, it's convenient to convert dates to numbers, e.g. Julian day numbers used by astronomers.  I'd do something like

sqlite3 mydata.db -csv '.import mydata.csv m' # import the CSV file to table 'm'

sqlite3 mydata.db 'select julianday(date),col3,col4 from m'   # spit out the data

or actually use the sqlite extension in Octave to read the database directly instead of using []=system()


- it's easier if the first line of the CSV file has column headers---they become the SQL column names

- actually, since your dates use / instead of - for separator, and separates date and time, and doesn't specify timezone, it'd be

sqlite3 mydata.db 'select julianday(replace(date,"/","-")||" "||time,"localtime"),col3,col4 from m'

Help-octave mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]