tags:

views:

48

answers:

2

I want to import really clean .txt files into Mysql with PHP. I've read that this is easy if you know the delimiter. but I don't.

In my case, the .txt files look like tables - ie: they're still structured like tables, not like a standard, jumbled CSV file.

Does this mean I don't have a delimited file? If so, any advice on how I might approach importing?

Thanks!

Terry

A: 

Sometimes the delimiter is the column number, rather than a character.

I.e. each data column begins in a specified physical character column. Each column is a fixed width, and parsing is as simple as splitting the string on those character width boundaries, and trimming whitespace if needed.

John Weldon
Delimited and fixed width files are not the same. Fixed width files tend to be supplemented by a definition file telling what columns go where. Columns are normally aligned either left or right, and usually padded with blanks although sometimes with zeros. Delimited files are files that are using a special character to indicate the end of a column.
simendsjo
Ah.. Sorry, re-read the question, and it sounds like he's talking about a fixed width format.
simendsjo
A: 

Sorry about that. An example would obviously help.

Here's an idea of what it looks like - ie: it already looks like a table.

https://gist.github.com/9753ad04b0fab256e452

saltcod
For future reference you should add corrections and clarifications by editing your question, not posting them as a solution.
BenV