Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It looks like there was a failed attempt to establish a session with a mysql server? Then I guess you got a CSV file with the data you wanted?

Some recommendations:

  1. Manually import this CSV into an Excel spreadsheet to see what Excel itself makes of it. Under File, Open, then Excel will see that this is a CSV file and will give options on how to import it.
  2. To parse the CSV file, you should use Text::CSV. This: my @t= split(',',<FH>); is not what you want. The CSV format looks simple but in fact is devilishly difficult to parse correctly in all boundary cases.
  3. Deciding if a line is of interest or not is probably a regex that you run vs phone number. This: length($t[7]) == 10 may not be a very robust test due to imbedded spaces and the like...I would probably look at what exactly is in the CSV file before I decided what to do about it.
  4. You could put just a few lines of the CSV file between code tags in your post so that we see what it is. Choose carefully lines that illustrate you point (one with 10 digit phone number, one with different phone number) etc...
  5. If you are comfortable with SQL, there is a DBI driver for CSV files. That may or may not work out well for your application. It has been many years since I used this driver, but before SQLite, it was a pretty good tool.

Update: See DBD::CSV for some examples of how to open and use your CSV file like a DB.

while (<FH>){ my @t= split(',',<FH>); ....
This will throw away half the lines ... the while statement reads a line into $_. The split reads another line.
This is closer to what you want, but inferior to using Text::CSV. If your CSV has a field with an embedded comma: "343 Anywhere, Apt 12", then split on comma will see that internal comma and you get an "extra" token. Text::CSV will leave that embedded comma "as is".
while (<FH>){ chomp; my @t= split(',',$_);

In reply to Re: Reading, filtering one collumns' data, writing by Marshall
in thread Reading, filtering one collumns' data, writing by MoodyDreams999

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2023-10-03 10:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found