User Tools

Site Tools


windows:aboutexcelcsvformat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
windows:aboutexcelcsvformat [2014/10/29 12:10] – [The CSV format] rlunarowindows:aboutexcelcsvformat [2022/12/02 22:02] (current) – external edit 127.0.0.1
Line 11: Line 11:
 What I've find out researching into the way Excel stores this information and making some tries is this:  What I've find out researching into the way Excel stores this information and making some tries is this: 
  
-  - The general format is this: +The general format is this: 
  
 <code>   <code>  
Line 18: Line 18:
 </code> </code>
  
-  - As ''<separator>'' you can use comma (,), semicolon (;) and tab characters (vbTab, 0x09) +As ''<separator>'' you can use comma (,), semicolon (;) and tab characters (vbTab, 0x09) 
-  If the character ''<separator>'' and in one of the values is a separator character, you have to put it among double quotes. Let's say that the separator is semicolon, and the first value is "hello;world". The final codification of this would be: + 
 +If the character ''<separator>'' and in one of the values is a separator character, you have to put it among double quotes. Let's say that the separator is semicolon, and the first value is "hello;world". The final codification of this would be: 
      
 <code>   <code>  
Line 26: Line 27:
 </code> </code>
      
-  - **How the carriage returns in the values are treated???** They are treated the same as the separator: if they are among a value, you have to put the value into a double quotes. Let's say that the third value has a carriage return. In that case, ''(foo\r\nbar)'', then you have to code it like this:+**How the carriage returns in the values are treated???** They are treated the same as the separator: if they are among a value, you have to put the value into a double quotes. Let's say that the third value has a carriage return. In that case, ''(foo\r\nbar)'', then you have to code it like this:
      
  
Line 34: Line 35:
 </code> </code>
  
-  - **What happens with the lenght of the values???** The maximum length per record is 32,768 **bytes** (sounds familiar, isn't it?). Pay attention to the "bytes", because if we are using Unicode as our encoding standard, the number of characters might not be equal to the number of bytes. You have to cut values longer than that because otherwise, excell will do it for you, putting the rest of the data in the following line. +**What happens with the lenght of the values???** The maximum length per record is 32,768 **bytes** (sounds familiar, isn't it?). Pay attention to the "bytes", because if we are using Unicode as our encoding standard, the number of characters might not be equal to the number of bytes. You have to cut values longer than that because otherwise, excell will do it for you, putting the rest of the data in the following line. 
      
      
Line 46: Line 47:
 ===== A reference implementation in visual basic script ===== ===== A reference implementation in visual basic script =====
  
-Here is my reference implementation in visual basic script, which can be easily converted into other programming language like java.+Here is my reference implementation in visual basic script (provided the input comes from a recordset), which can be easily converted into other programming language like java
 + 
 +As a safety precaution, I've put behind double quotes any value that contains a "cr" or "lf" character in it.
  
 <code vbs> <code vbs>
Line 153: Line 156:
  
  
 +
 +----
 +
 +~~~DISQUS~~~
  
  
windows/aboutexcelcsvformat.1414581033.txt.gz · Last modified: 2022/12/02 22:02 (external edit)