On Feb 20, 2008 3:05 AM, Richard Lynch <ceo@xxxxxxxxx> wrote: > On Mon, February 18, 2008 12:08 pm, Graham Cossey wrote: > > proceed accordingly... My biggest gripe with tab delimited files is > > that they are quite a bit bigger than comma delimited files so I may > > have to split the large files I receive into smaller 'chunks' to allow > > them to be uploaded. > > This is not making sense... > > A tab-delimited file wil have a TAB character "\t" instead of comma "," > > A tab WITHIN the data then needs escaping as "\t" or somesuch. > > But commas to not need escaping with quotes. > > And quotes don't need escaping with double-quotes. > > So tab-delimited should be a TINY bit smaller or the same size. > > Perhaps your users are just uploading more data. > > > One thing I have noticed is that the files I create in my PHP script > > (The script breaks a large file into smaller files of 25,000 > > records/rows each.) when opened in Excel (by double-clicking the file > > in Windows Explorer) came up with an unrecognised file format message > > for all files except the first. If you ignore this message the tab > > delimited files open OK but the comma separated ones do not. The > > "except the first" made me think that there may be something "hidden" > > at the beginning of the file to say what type of data follows. > > Some CSV files include a "header" line with the names of the fields in > the first line. > > This is less common in tab-delimited, but not unheard of. > If it's any help the data I'm getting comes out of a third party Cognos environment. The data opened into Textpad looks like this : Column One Column Two Column Three Column Four Column Five Column Six Column Seven ABCDE XX99 DCS HORSE 1 2006 02 ABFED XX99 DCS HORSE 1 2006 02 JHGNF XX99 DCS HORSE 1 2006 02 HNDGE XX99 DCS HORSE 1 2006 02 Tab delimited no? This file is 385KB. If I open it into Excel just by double-clicking on it it opens fine. I then do File > Save As, change Unicode Text (*.txt) to CSV (Comma Delimited)(*.csv) and give it a name then Save. This new file is now 193KB and looks like this in Textpad : Column One,Column Two,Column Three,Column Four,Column Five,Column Six,Column Seven ABCDE,XX99,DCS,HORSE,1,2006,2 ABFED,XX99,DCS,HORSE,1,2006,2 JHGNF,XX99,DCS,HORSE,1,2006,2 HNDGE,XX99,DCS,HORSE,1,2006,2 Double-clicking on this newly created file opens fine into Excel. Back to my 'original' problem/question, if I '$f = fopen("$file", "r")' and 'while ($data = fgets($f))' on the above first format and do a $data = str_replace("\t",",",$data); the resulting file looks like the second example above when opened into Textpad but will not open into separate columns when opened with Excel. I thought these were supposed to be simple, basic flat text formats that were universally accepted, guess I'm just naive ;-) I'm on the verge of simply giving in, and continuing to Open & Save As the 100+ files I have to process in the next week or so :-( -- Graham -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php