• 0

Scripting/automating editing a text file


Question

Hi guys,

 

I have a text file generated by a weather forecasting program.
It has alot of data that doesn't work with a PHP script I use, so I need to delete it out manually.

What I need to do is automate this somehow - I need it to delete everything before a certain block of text that is always the same. The line that is always the same is "   WXSIM text forecast for Glendale". So everything before that is deleted, and everything after stays.

 

Any ideas or solutions?

Thanks! :-)

3 answers to this question

Recommended Posts

  • 0

Just automate it in PHP itself, text filtering should be doable using regex for example.

 

If you could post before/after examples of the text you want to input and what the output should look like, I could make a better assumption on the best solution.

 

Regex can also be done in most other programming languages so this could also be made as a shell script or executable.

  • 0

Since you're literally splitting the text input something like a simple split function should probably already work:

 

$output = ($input, "   WXSIM text forecast for Glendale")[1];

 

If details like Glendale are variable(different between files) then you probably need to use regex.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.