Want VBA in excel to read very large CSV and create output file of a small subset of the CSV

前端 未结 7 1957
故里飘歌
故里飘歌 2020-11-30 08:18

I have a csv file of 1.2 million records of text. The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not.

For example \"Fre

7条回答
  •  自闭症患者
    2020-11-30 08:32

    Look at the Input # statement in the Excel help

    Sample usage would be:

    Input #fnInput, s_Forename, s_Surname, dt_DOB, i_Something, s_Street, s_Town, s_County, s_Postcode
    

    and then use the Write # statement to write matching records out again

    The only issue might be that the date format in the output will end up as #1967-07-01# but this format is unambiguous unlike 01/07/1967 which would represent 1st July in the UK and 7th January in the US. If you need to preserve the formatting of the date then write it out as a string:

    s_DOB = Format(dt_DOB, "dd/mm/yyyy")
    

提交回复
热议问题