Runtime error in FillSeriesFromFile: Input string was not in a correct format
Author: quaresma
Creation Date: 9/12/2019 12:39 PM
profile picture

quaresma

#1
Hi, i wiil try to create indicator from csv file. Data from the csv has the following format:

timestamp,open,high,low,close,volume,volume_buy,count

2017-01-01 01:00:00,968.49,968.76,964.54,968.0,384541.0,189386.0,132.0

2017-01-01 02:00:00,968.09,968.1,963.4,963.4,355937.0,125474.0,122.0

I tried to use the option FillSeriesFromFile to convert this data to DataSeries Wealth Lab, but keep getting the error " Runtime error: Input string was not in a correct format". Perhaps I incorrectly specified the DateTime ToString format? Help to understand, thank you

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Hi,

I think the routine should have better success importing the data if you get rid of the header and space between the lines:

1. Header:
QUOTE:
timestamp,open,high,low,close,volume,volume_buy,count

2. Space between lines:
QUOTE:
2017-01-01 01:00:00,968.49,968.76,964.54,968.0,384541.0,189386.0,132.0

2017-01-01 02:00:00,968.09,968.1,963.4,963.4,355937.0,125474.0,122.0

Not just one but both.
profile picture

quaresma

#3
Eugene, Thank you for your response.
I did everything You recommended. Removed the spaces between the lines and the header, but still get the error Runtime in A CORRECT FORMAT. Do you run this code with my data? Does it matter which data I want to run it on?
The data now looks like this:
2017-01-01 01:00:00,968.49,968.76,964.54,968.0,384541.0,189386.0,132.0
2017-01-01 02:00:00,968.09,968.1,963.4,963.4,355937.0,125474.0,122.0
2017-01-01 03:00:00,964.6,964.6,963.16,964.26,160422.0,57370.0,43.0
profile picture

Eugene

#4
Gotcha. You've got an error in the date/time specifier:
CODE:
Please log in to see this code.

The "mm" is for minute, "MM" is for month. You can learn more about them here:

Standard Date and Time Format Strings
Custom date and time format strings
profile picture

quaresma

#5
Ok, thank you for paying attention to the string format
I fixed this error in this line, but at start still indicates the same problem about string format.
Does the number of values in the file matter?
What else can I do wrong? I attached a file that I'm trying to parse
profile picture

Eugene

#6
Not sure what's wrong because I can see the chart correctly rendered with your sample data as expected. Note, however, that FillSeriesFromFile is suboptimal for your data which includes OHLC. An easier solution would be to use the ASCII data provider and define the last 2 columns ("volume_buy,count") as Named DataSeries.

For more details please refer to the QuickRef > Bars object > FindNamedSeries, HasNamedDataSeries and NamedSeries .
profile picture

quaresma

#7
Ok, I thanks, I'll try to do it
profile picture

Eugene

#8
Last but not least. It's called Custom Field in the ASCII provider. Please find more info in the User Guide > Data > Data Manager > Create New DataSet > Data Providers > ASCII.
profile picture

quaresma

#9
Eugene, thanks! It's job
profile picture

Eugene

#10
Glad I could assist.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).