niche Posted September 2, 2015 Share Posted September 2, 2015 (edited) I have a totally flat text file (nondelimited) with a record length of 120. How do I finish this query to send every 120 characters to the row named raw which is a varchar with a width of 120? LOAD DATA LOCAL INFILE'e:/usps/crs1508b/685.txt'INTO TABLE crisSET raw = Edited September 3, 2015 by niche Link to comment Share on other sites More sharing options...
justsomeguy Posted September 2, 2015 Share Posted September 2, 2015 I don't think MySQL provides a way to do that. You might want to write a small script to break the file up and either save it as a delimited file or insert records directly. A stored procedure could probably do that also. Link to comment Share on other sites More sharing options...
niche Posted September 2, 2015 Author Share Posted September 2, 2015 That saved me another hour of fruitless search. My hats off to you as always JSG. What do you think of a php while loop with a query in it? You don't seem sold on the stored procedure route. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 2, 2015 Share Posted September 2, 2015 It would be more efficient to just reformat the file and then load the new file the same way, queries in a loop can run into problems pretty quick. Link to comment Share on other sites More sharing options...
niche Posted September 2, 2015 Author Share Posted September 2, 2015 Reformat how? I don't understand where you're going? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 3, 2015 Share Posted September 3, 2015 Use PHP to parse the data and split it up into the individual values you want to insert, and rebuild the file in a delimited way that MySQL will understand. 1 Link to comment Share on other sites More sharing options...
niche Posted September 3, 2015 Author Share Posted September 3, 2015 Viola! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now