ASCII Data Provider: error
Author: dansmo
Creation Date: 3/12/2010 8:37 AM
profile picture

dansmo

#1
ASCII Provider:

the file I am trying to import has the following style:

QUOTE:
"Date","Time","Open","High","Low","Close","Up","Down"
01/12/2000,1245,6880.5,6888.0,6880.0,6886.0,190,0
01/12/2000,1250,6885.5,6887.0,6877.5,6879.0,135,0
01/12/2000,1255,6880.5,6887.0,6880.0,6884.0,117,0
01/12/2000,1300,6883.5,6894.5,6883.5,6894.0,348,0


I get the following error:
QUOTE:

"String was not recognized as a valid DateTime"

The error is on the last line of the above snippet.
Field: 1300

Settings:
Date Format: MM/dd/yyyy
Time Format: hhmm
Field Separator: Comma
Decimal: Period
Thounsands: none

Am I doing someting wrong with the settings??
profile picture

Eugene

#2
According to MSDN > Custom DateTime Format Strings, "hh" displays the hour for the specified DateTime in the range 1-12, whereas your time is in the range 0-23. Try selecting HHmm as the DateTime format.
profile picture

dansmo

#3
Understood. Thank you.
profile picture

maninjapan

#4
Im having a similar problem. Im using time as follows, but it returns an error when it gets to the line for midnight. I am using the time Format Hmm in WLD5. I tried changing it to 000, but that didnt work either.

1/2/2005,2330,222.328125,222.25,180
1/2/2005,2335,222.15625,222.15625,6
1/2/2005,2350,222.15625,222.15625,3
1/2/2005,2355,222.25,222.25,21
1/3/2005,0,222.234375,222.234375,11
1/3/2005,05,222.234375,222.234375,2
1/3/2005,10,222.15625,222.15625,7
profile picture

maninjapan

#5
UPDATE****

I just added 00 fro the mignight hour (full time is 0000, 0005, 0010....) This seemed to pass, but pulled up an error when it got to 100 . According to the explanation in the link above , the hour only needs to be single digit, correct?
profile picture

Eugene

#6
No, it's not a similar problem - rather a case of GIGO: Garbage In, Garbage Out.

"05", "10" and especially "0" do not adhere to the "Hmm" format, and I'm afraid to any format at all. What happens here is that out of the blue, the nice "Hmm" format changes to... "mm" (until the 2nd hour starting with 100, right?)

Edit****
QUOTE:
the hour only needs to be single digit, correct?

No. Since "H" describes the hour in the range 0-23, you should add "0" to the midnight hour, not "00".
profile picture

maninjapan

#7
Sorry thats what I meant, Single digit numbers 0-9, dont need to be changed to a 2 digit number, correct? so 00:30 would be 030, and 01:30 am would be 130. Which is what I just tried, but still recieve an error.

1/2/2005,2355,222.25,222.25,21
1/3/2005,000,222.234375,222.234375,11
1/3/2005,005,222.234375,222.234375,2
1/3/2005,010,222.15625,222.15625,7
1/3/2005,015,222.25,222.25,3
1/3/2005,020,222.25,222.25,5
1/3/2005,025,222.15625,222.15625,4
1/3/2005,030,222.15625,222.15625,28
1/3/2005,040,222.25,222.25,70
1/3/2005,045,222.25,222.15625,7
1/3/2005,050,222.25,222.328125,13
1/3/2005,055,222.25,222.25,4
1/3/2005,100,222.328125,222.328125,2
1/3/2005,130,222.34375,222.171875,462
1/3/2005,135,222.34375,222.25,20
1/3/2005,140,222.25,222.171875,
profile picture

Eugene

#8
QUOTE:
Which is what I just tried, but still recieve an error.

Ah. Right. Although it should work, but unfortunately will not.

There is a known issue in .NET 2.0 (known to us, but did Microsoft know? also, I'm not sure about other versions of the framework) with the "Hmm" time format. Take this simple example:
CODE:
Please log in to see this code.

The correct string "935" can't be converted to a DateTime using the "Hmm" format (InvariantCulture is here to ensure we're not dependent on particular regional settings).

In other words, the "Hmm" format is problematic in .NET 2.0 and I suggest changing to a different one.
profile picture

Eugene

#9
The ASCII Provider will support the "Hmm" and "Hmmss" time formats, starting from version 1.3.
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).