Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><P>I know this is an old question, but the problem is not going away soon. CSV files are easy to generate from most programming languages, rather small, human-readable in a crunch with a plain text editor, and ubiquitous. <P>The problem is not only with <strong>dates</strong> in text fields, but <strong>anything numeric</strong> also gets converted from text to numbers. A couple of examples where this is problematic: </p> <ul> <li>ZIP/postal codes</li> <li>telephone numbers</li> <li>government ID numbers</li> </ul> <p>which sometimes <strong>can</strong> start with one or more zeroes (0), which get thrown away when converted to numeric. Or the value contains characters that can be confused with mathematical operators (as in dates: /, -). <P>Two cases that I can think of that the "prepending =" solution, as mentioned previously, <strong>might not be ideal</strong> is</p> <ul> <li>where the file might be imported into a program other than MS Excel (MS Word's Mail Merge function comes to mind),</li> <li>where human-readability might be important.</li> </ul> <h1>My hack to work around this</h1> <p>If one pre/appends a non-numeric and/or non-date character in the value, the value will be recognized as text and not converted. A non-printing character would be good as it will not alter the displayed value. However, the plain old space character (\s, ASCII 32) doesn't work for this as it gets chopped off by Excel and then the value still gets converted. <strong>But</strong> there are various other printing and non-printing space characters that will work well. <strong>The easiest</strong> however is to <strong>append (add after) the simple tab character (\t, ASCII 9).</strong></p> <p>Benefits of this approach:</p> <ul> <li>Available from keyboard or with an easy-to-remember ASCII code (9),</li> <li>It doesn't bother the importation,</li> <li><em>Normally</em> does not bother Mail Merge results (depending on the template layout - but normally it just adds a wide space at the end of a line). (If this is however a problem, look at other characters e.g. the zero-width space (ZWSP, Unicode U+200B)</li> <li>is not a big hindrance when viewing the CSV in Notepad (etc),</li> <li>and could be removed by find/replace in Excel (or Notepad etc).</li> <li>You don't need to <em>import</em> the CSV, but can simply double-click to <em>open</em> the CSV in Excel.</li> </ul> <p>If there's a reason you don't want to use the tab, look in an Unicode table for something else suitable.</p> <h1>Another option</h1> <p>might be to generate XML files, for which a certain format also is accepted for import by newer MS Excel versions, and which allows a lot more options similar to .XLS format, but I don't have experience with this.</p> <p><P>So there are various options. Depending on your requirements/application, one might be better than another.</p> <hr> <h1>Addition</h1> <p>It needs to be said that newer versions (2013+) of MS Excel don't open the CSV in spreadsheet format any more - one more speedbump in one's workflow making Excel less useful... At least, instructions exist for getting around it. See e.g. this Stackoverflow: <a href="https://stackoverflow.com/questions/17953679/how-to-correctly-display-csv-files-within-excel-2013">How to correctly display .csv files within Excel 2013? </a>.</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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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