Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing text file CSV

Status
Not open for further replies.

ghayman73

Technical User
Jul 3, 2002
55
0
0
FR
I have a CSV file that i want to import into access but it comes with information on the first 6 lines that i do not want, is there a way of skiping the first few record so that it starts reading on line 7.

I have seen this done in excel you but dont seem to be able to save the import structure to re-use for diffrent files like you can in access.

Any help would be appreciated.

Grant
 
Hi,

Perhaps this solution can help you. In this example the textfile has some lines with crap, and then the lines with data. Now the craplines are a lot shorter than the datalines.
So I check which lines are longer than 50 and write these into another textfile. AFter doing this, I import the second file which contains the data

The code:

'the file containing crap + data
Open "C:\TEMP\oudbkl1th.txt" For Input As #1
'the file that will contain only data. This file doesn't have to exist!
Open "C:\TEMP\oudbkl1hvtimport.txt" For Output As #2
Dim Hold As String
Do Until EOF(1)
Line Input #1, Hold
If Len(Hold) > 50 Then
Print #2, Hold
End If
Loop

Close #1
Close #2


Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top