Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The sample text you supplied seems to be separated either by tabs or spaces (column aligned?). It is important to know which, or the regexp will not work. It is also important to know whether the pattern is consistent throughout the file.</p> <p>If it is aligned by columns, the easiest and probably safest way is to simply count off characters. E.g.:</p> <pre><code>s/(^.{20})(\S*) /$1"$2"/; </code></pre> <p>(You will have to adjust the number 20 yourself. I just approximated.) </p> <p>Note that I am chopping off two spaces at the end of the name field in a reckless manner. This is to not screw up the format for the following values. If however the field is filled to the brim, there might not be two spaces at the end, and the regexp will miss. But then, on the other hand, you would not be able to fit quotes there anyway.</p> <p>When dealing with these types of files, I do not think it is safe to use generic searches. If you are counting on commas to only appear in the names, sooner or later you will find someone who thought that "Bronx, New York" should be in the city field, and your regexp will be screwed.</p> <p>A somewhat more strict, but complicated regexp would include the previous fields:</p> <pre><code>$date='\d{2}-\d{2}-\d{2}'; # this might work for dates such as 11-10-23 s/^(\d+\s+$date\s+)(\S+) /$1"$2"/; </code></pre> <p>Same thing here, if the name field is not big enough to fit two quotes, it won't be added. You should check your file and see if that is ever the case. If it is the case, you will need to deal with it somehow.</p> <p>I sometimes find that putting certain field's regexps in separate variables helps with legibility, such as with $date above.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload