Jump to content

How do I use and Gather Information from a Txt file that has been uploaded?


Recommended Posts

Ok Basically I need to know how to do this:

 

 

I upload a txt file that contains this:

 

"MLE ",20,"2057NALL       ","ND ","Amber for 2057 1         ","!Amber for 2057          ",00003.65,00001.02                       
"MLE ",20,"211-2          ","D  ","Dome-Courtesy 10         ","!Dome-Courtesy 1         ",00001.60,00000.61                       

 

How would I get Information from each different line like the below:

 

2057NALL     |   Amber for 2057 1     |     00003.65     |     00001.02        
211-2           |   Dome-Courtesy 10   |     00001.60     |     00000.61        

 

Any help on this subject would be greatly appreciated.

 

PhotonicCoder

Ok here is something:

 

This will get everything 5 spaces in on the line

<?php
fread($fh, 5);
?>

 

And this will get the amount of lines:

 

<?php
$lines = file("upload/" . $_FILES["file"]["name"]);
      
      $lineCount = count($lines);
?>

 

But how do I choose the Individual line and get information from certain parts of the text?

 

PhotonicCoder

 

But how

Your question is pretty ambiguous.  As in, no one really understands the question.

 

<?php
$lines = file("upload/" . $_FILES["file"]["name"]);
echo '<pre>';
for($i = 0; $i < $lineCount; $i++) {
if(empty($lines[$i])) { continue; }
$parts = explode(',',$lines[$i]);
echo str_replace('"','',$parts[2]) . ' | ' . str_replace('"','',$parts[4]) . ' | ' . str_replace(array('"','!'),'',$parts[5]) . ' | ' . $parts[6] . ' | ' . $parts[7] . "\n";
}
echo '</pre>';

 

In it's simplest form.

Unfortunately realized that this was ambiguous, however Thank you so much for this so I can get farther down the road. I will mark this topic solved after I go over it.

 

Thank you again for that jcbones!

 

PhotonicCoder

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.