2 Replies - 429 Views - Last Post: 26 January 2009 - 04:10 PM Rate Topic: -----

#1 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

reading files

Posted 26 January 2009 - 03:29 PM

Okay, I've got some wierd issues in reading a file, specifically by the way they are organized, its a txt file but the data is organized by what i thought was tabs, but i tryed exploding it by \t and it didnt work, i tryed ' ' and it did some but nothing that made sence, i guess when a column had a space in it then it did that., so I load the files into excel and what i thought was each tab is now a column in excel, so my question and problem is that I dont know how to parse through the lines after i read them in.

this is how I read the file in:
                $handle = fopen($var, 'r');
		if ($handle) {
			while (!feof($handle)) {
			$entries[sizeof($entries)] = fgets($handle);
		}
		}
		fclose($handle);


So im loading every line as a new array entry. now in this file when i open it up even the empty columns are their just empty but i only read in whats their, so im not sure how i can even split this up, Ill try working on making a dummy file so you guys can look at it, since the one I have contains personal information.

Edit: just a note, when i did file->save as in excel i said (tab deliminated), but then how come when i did \t it didnt work? maybe when i read it in it got rid of the tab spacing, is their a way to read it in with the tab spacing?....
Thank you,
Musya

This post has been edited by musya: 26 January 2009 - 03:32 PM


Is This A Good Question/Topic? 0
  • +

Replies To: reading files

#2 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: reading files

Posted 26 January 2009 - 03:36 PM

Okay here is a dummy file of how its seperated.

Attached File(s)

  • Attached File  test.txt (140bytes)
    Number of downloads: 37

Was This Post Helpful? 0
  • +
  • -

#3 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: reading files

Posted 26 January 2009 - 04:10 PM

never mind I got it figured out with fgetcsv($handle, 0, "\t");
just reads it in as an array and so it was the fact that fgets king of got rid of the \t deliminator.

Thank you anyway guys.
Musya
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1