Hi, got stuck on data import from CSV file. The file is formated in a sligthly strange way:
"London","182.56","12/12/2007"
"Paris","133.41","27/12/2007"
I get into problem when importing using default CSV settings as numbers and date are understood like text. I need to replace "." with "," to get to number format. Used following code:
Range("J5:K9999").Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
However I get values multiplied by 100 for some reason.
Converting date format gets eeven more complicated.
So I decided I can not use standard CSV import and need to define separate data source for each raw fileThis is not what I wanted, since I do import many files (10 at this point in time, but it will get growing). However, I would be ready to do that if there is no other option. So I go to "Create New Data Source" and under "Connect" I get to another input box called "ODBC Text Setup" where I select "Options" to define customer format. However, after selecting source file, Excel is not able to interprate fields. Tried clicking "Guess" button, no luck there. Thought it is because fo those "" before and after field value. So, just for a sake of experiment I opened file in text editor and removed those ". Still, can not read the file. The error message says "Text file specification field separator matches decimal separator or text delimiter. Guess failed"
I am out of ideas how to get this file properly imported. Hope there is a way to do that either by defining field formats while importing (perhaps that can be done via SQL, but I am not confident with it) or writing some code to change format after importing from text to Number and Date...
Bookmarks