Loading...
Pages: [1]   Go Down
Author Topic: Calculating csv file size  (Read 651 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am logging sensor data to a scv file. I need to calculate the size of this csv file before sending it over to the serial port.

any one with experience on this......
Logged

Netherlands
Offline Offline
Tesla Member
***
Karma: 90
Posts: 9421
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Can you be more specific?

What OS?
What is in the CSV?
How many fields?
What datatype is every field?
How do you want to send the data?
- binary/ascii
- uncompressed/compressed
- otherwise

The more you tell about the problem the better help you get

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 316
Posts: 35535
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where is the csv file stored? If the csv file is on an SD card, the SD library has a way to determine the size of a file.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you guys for getting back to me.
I am logging sensor data into 4 fields (Date time, sensor number, sensor reading 1 and sensor reading 2) into csv format to an sd card on an arduino uno.
all of the fields are integers, (Separated by commas).
i would like to send data to a satellite modem in binary format. So to successfully send the message, the modem has to know the  length, in bytes, of the message the arduino is sending.

so the challenge is for the arduino to tell the modem that it is sending binary data of a certain length and in response, the modem receives that message and calculates its length. if it is incorrect, it will send an error message to the arduino.

regards
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 316
Posts: 35535
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i would like to send data to a satellite modem in binary format. So to successfully send the message, the modem has to know the  length, in bytes, of the message the arduino is sending.
Are you planning to send the whole file in one package? That will require reading the whole file, and storing it in SRAM, of which you have only 2048 bytes (and the SD library needs 512+ of them). If so, simply count the characters as you read them from the file (you'll need to do that to store them in the correct place in the array, anyway).

If not, and this is the more likely scenario, then the size of the csv file is irrelevant. It is the size of the package that you need to know. And, that depends on how you want to package data to be sent. Maybe, one record at a time. Of course, this requires that you know what a record looks like (i.e. when it ends).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am working with binary data now and i am looking for a way of finding the length of a binary file
Logged

'round the world...
Offline Offline
Edison Member
*
Karma: 20
Posts: 2308
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

End address - Start Address = size

Sorry for being so short, but it's not like you provided a lot of info...
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
End address - Start Address = size
sp. "(End address - Start Address) + 1 = size"   smiley-wink
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Global Moderator
Melbourne, Australia
Offline Offline
Shannon Member
*****
Karma: 219
Posts: 13896
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

- Moderator
Logged


Pages: [1]   Go Up
Print
 
Jump to: