flat file converting string to integer / column headings

eatmoreoat
edited February 11, 2022 in Analytics #1
Hi,

I've a very simple csv file of the format <epoch seconds>,<value>

1210269001,0.219289541244507
1210269301,0.21416974067688
1210269601,0.207547187805176
etc

My goal is to graph this data (date on x-axis, value on y-axis).

I don't seem to be able to convert the epoch seconds column from a String into an Integer for conversion by Date() unless I insert column headings, which I can't since its a generated data file.

Without column headings, originally I started with a computed column called longdate computed as follows :

new Date(row["1210269001"] * 1000);

This always returned "Dec 31, 1969 7:00 PM" since Date expects a number, not a string, so was apparently effectively 0 or something. So then I tried this :

new Date(Integer.parseInt(row["1210269001"]) * 1000);

This generates an error during preview :

"The data type of computed column "longdate" is java.lang.Integer, but one of its value is "null", which cannot be converted to java.lang.Integer."

So finally, I tried modifying the data file by adding column headings, secs and value :

secs,value
1210269001,0.219289541244507
1210269301,0.21416974067688
1210269601,0.207547187805176

And then new Date(row["1210269001"] * 1000); worked fine. So my final question is how do I do this WITHOUT the inserted column headings of secs, and value ? Is it even possible ?

Thanks a bunch.
-Dom

Comments

  • eatmoreoat
    edited December 31, 1969 #2
    oops that last line that works meant to read new Date( row["secs"] * 1000);
  • eatmoreoat
    edited December 31, 1969 #3
    Answering my own question - in the end, I found row[1] , row[2] etc to work fine.