• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 664
  • Last Modified:

How to count number exact size or byte in a csv file

Dear Experts,
I get one csv file  with the following  simple structure saved in ANSI format
1,2,3
4,5,6
7,8,9
The total size in my window folder show the size is 30byte , so I try to count it , every data is two byte in ASCII format
so there should be 2 byte * 5 data in 3 rows (including ",")= 30 Bytes but I wonder why that doesn't  include
line-return two byte for every row. The line-return code should be inside of the csv file, otherwise how
can I extract the csv file data from recongizing  every line by line-return, for example, we are using
var dataRows = data.split( "\n" ); in javascript  to move next  line,  or $line_of_text = fgetcsv($file_handle, 1024) in php.


If it is true, it should be total size= 36 bytes instead of 30 bytes. ? OR for ANSI file, window doesn't count
line-return byte for the final size of the file ?


Please advise.

Duncan




var dataRows = data.split( "\n" )
0
duncanb7
Asked:
duncanb7
  • 4
  • 2
1 Solution
 
yadayaCommented:
--> "," not a two byte integer, just one byte char. so:
2*9(two byte integer) = 18
+
6( ",")
+
3*2("\n")
=
30 bytes
0
 
duncanb7Author Commented:
http://en.wikipedia.org/wiki/File:ASCII_Code_Chart.svg, I look into ASCII code table
it specified those key in 2 byte such as 2C(hex)  for ",".

IS my concept wrong, the ASCII table is for keyboard only not for file system ?

0
 
duncanb7Author Commented:
Because when I edit it in Excel and save it into csv file so it will create space when you hit return for next cell edit
so 1,2,3 will be  1 ,2 ,3  shown in notepad++,  And if true, every key is one byte and control-key like "\n" is two byte.  So every row will  be 3 space+ 3 number +2 of "," + "\n"=10 byte, and 3 row*10=30 byte for total size.
You could test it in notepad++

Number and char or space  is also in 1 byte, Control-key is 2 byte.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
yadayaCommented:
I look into ASCII code table
it specified those key in 2 byte such as 2C(hex)  for ",".

"2c " not two bytes, its one byte.
Byte = 8 bit or 0-255 in decimal, 00-FF in hex/
0
 
duncanb7Author Commented:
In ASCII table, FF is presenting 1 byte only 4-bit + 4bit =8-bit or one byte for keyboardsystem that is not
same as a char of "FF"

So it is clarifed ,
0
 
duncanb7Author Commented:
Thanks for your reply.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now