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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to import a 3 line text file 1

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
Hello everyone

I have a text file which is a list of customers records. the problem is that everyone records expands on 3 lines.

is there an easy way to import to a database or excel file.

thank you for any help.

villica
 
import the file into access and add autonumber named importtable
field named custext




Code:
Select importtable.custext, line2.custext, line3.custext into customertable
from importtable 
inner join importtable line2
on importtable.id =  line2.id+1
inner join importtable line3
on importtable.id =  line3.id+2
where (importtable.id = 1) or (importtable.id mod 3 =0)
 
thanks pwise. This is going to be a dumb question. LIne2, line3 so on are fields names correct.

I am getting a syntax error

on importtable.id = (line2.id+1)
inner join importtable line3
on importtable.id = line3.id+2

villica
 
Sorry I forgot access syntex add prenteces

Try

Code:
Select importtable.custext, line2.custext, line3.custext into customertable
from (importtable 
inner join importtable line2
on importtable.id =  line2.id+1)
inner join importtable line3
on importtable.id =  line3.id+2
where (importtable.id = 1) or (importtable.id mod 3 =0)

LIne2, line3 so on are fields names correct.

Wrong line2,line3 are alises for the table for a self join
 
Id replace this:
where (importtable.id = 1) or (importtable.id mod 3 =0)
with this:
where (importtable.id mod 3 = 1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top