Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Remove Tabs and Newlines Inside Fields of Text Tab Delimited Files from Excel

by choroba (Cardinal)
on Jul 13, 2016 at 15:25 UTC ( [id://1167697]=note: print w/replies, xml ) Need Help??


in reply to Remove Tabs and Newlines Inside Fields of Text Tab Delimited Files from Excel

If you want to see some wild data to test your code against, check the tests of Text::CSV_XS and/or Text::CSV_PP.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
  • Comment on Re: Remove Tabs and Newlines Inside Fields of Text Tab Delimited Files from Excel
  • Download Code

Replies are listed 'Best First'.
Re^2: Remove Tabs and Newlines Inside Fields of Text Tab Delimited Files from Excel
by perldigious (Priest) on Jul 13, 2016 at 15:56 UTC

    You piqued my curiosity. I'm presuming what you meant is that they have a standard predefined set of test files to run code changes against. I see references in the code to test.csv and test.txt, but I don't see links to those files anywhere to look inside and presumably have my face twist in horror (I'm glad I was never dumb enough to try to deal with CSV files myself btw).

    I have come to the conclusion that I'd like to start learning and using the Perl DBI if I can find some free time at work to do so. Not just to do the types of things I'm already doing in tab delimited files, but if I could actually talk my company's admins in to giving me direct read access to our Oracle database I feel like I could suddenly have a lot more power to do useful things. As it is, I suffer from having to output multiple flat files from our web form based database inquiry tool we pay for and then having to parse and cross reference the data in those files myself using Perl... which is why I learned and learned to love Perl in the first place actually

    I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
    I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious

      Most modules on CPAN come with tests (and those which don't should). When the module is installed by the user there are four steps which should always be run on the unpacked tarball. These are:

      1. Produce the makefile or the build script
      2. Make/build the distro from the source
      3. Run the tests
      4. Install into @INC

      The tests in step 3 are the ones which we're talking about here and by convention live in the top-level t/ directory. For example, here's where they are in Text::CSV_XS. You can view the results of the tests being run on a wide variety of platforms at CPAN Testers.

      You can use these tests as a basis for some you run against your own code to see how it handles the various edge cases, etc.

        I work exclusively in Windows environments (for better or worse) and use Strawberry Perl, so I'm spoiled on the simple "cpan module_whatever" command for installs (I presume it does all those things for me?). I have on a few occasions had to go down a far more manual path involving downloading a module, creating the makefile, using "dmake", testing, and installing as you say. I'm so bad at remembering how to do it that I wrote the steps in to a bunch of tiny little scripts that I just run in order manually, though I'd guess I'll run in to something at some point where those don't work right either.

        I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
        I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious
      It seems the tests either create the files themselves or contain the data in the __DATA__ section.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167697]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found