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

Posted on 2011-04-25
Last Modified: 2012-05-11
Dear Experts,
I get one csv file  with the following  simple structure saved in ANSI format
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.


var dataRows = data.split( "\n" )
Question by:duncanb7
    LVL 3

    Expert Comment

    --> "," not a two byte integer, just one byte char. so:
    2*9(two byte integer) = 18
    6( ",")
    30 bytes
    LVL 13

    Author Comment

    by:duncanb7, 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 ?

    LVL 13

    Author Comment

    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.

    LVL 3

    Accepted Solution

    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/
    LVL 13

    Author Comment

    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 ,
    LVL 13

    Author Closing Comment

    Thanks for your reply.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 for Beginning Beginners

    Are you looking for an efficient introduction to HTML5? Have you tried other HTML5 courses and found them too complex? Do you need just the basics of HTML5 to use with Wordpress or other content management system? If you said yes to any of these questions, this course is for you.

    Suggested Solutions

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now