We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

duncanb7
duncanb7 asked
on
Medium Priority
1,068 Views
Last Modified: 2012-05-11
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" )
Comment
Watch Question

Commented:
--> "," not a two byte integer, just one byte char. so:
2*9(two byte integer) = 18
+
6( ",")
+
3*2("\n")
=
30 bytes

Author

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 ?

Author

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.

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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 ,

Author

Commented:
Thanks for your reply.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.