Hi all,
I am writing a program in C in which I need to read a data
file and export to the excel.The Data in the file in CSV format.
Values in the .txt file are as follows:
"a","b","c"
10,20,30
40,50,60
70,80,90
For that I need to read the values column wise.
Like I have to store the values in a buffer like the following:
"a",
10,
40,
70
etc.
I did the following:
1.Open the file in Read Mode
2.Read line by line
3.Search for comma
4.When Got comma
Printf("\n");
5.Problem is how I will return the buffer(Which is set of integers) to
calling program reading the data values column wise???
Regards
Bubunia 3 7594
Sobhan wrote: Hi all, I am writing a program in C in which I need to read a data file and export to the excel.The Data in the file in CSV format. Values in the .txt file are as follows: "a","b","c" 10,20,30 40,50,60 70,80,90
For that I need to read the values column wise. Like I have to store the values in a buffer like the following: "a", 10, 40, 70 etc.
I did the following:
1.Open the file in Read Mode 2.Read line by line 3.Search for comma 4.When Got comma Printf("\n"); 5.Problem is how I will return the buffer(Which is set of integers)
'a' is an integer, "a" is a pointer.
Is it supposed to be 'a' or "a" ?
to calling program reading the data values column wise???
--
pete
"Sobhan" <bu*********@yahoo.co.in> wrote in message
news:81**************************@posting.google.c om... Hi all, I am writing a program in C in which I need to read a data file and export to the excel.The Data in the file in CSV format. Values in the .txt file are as follows: "a","b","c" 10,20,30 40,50,60 70,80,90
For that I need to read the values column wise.
You can't. You can only read it a character at a time or a line at a time.
(Yes, yes, I know, there are other methods, but none of them "column wise".)
I did the following:
1.Open the file in Read Mode 2.Read line by line 3.Search for comma 4.When Got comma Printf("\n");
ITYM printf (lowercase p). This approach will work only for printing the
first column. It will not work if a) you want to make any sense of the items
in your first column, and/or if b) you want to read second (make it Nth)
column.
5.Problem is how I will return the buffer(Which is set of integers) to calling program reading the data values column wise???
Read a line at a time (fgets), parse it (sscanf, strtol or whatever is
suitable for your data format) and discard the rest of the line. Repeat for
every line. Simple.
Peter
Sobhan wrote: Hi all, I am writing a program in C in which I need to read a data file and export to the excel.The Data in the file in CSV format. Values in the .txt file are as follows: "a","b","c" 10,20,30 40,50,60 70,80,90
For that I need to read the values column wise. Like I have to store the values in a buffer like the following: "a", 10, 40, 70 etc.
I did the following:
1.Open the file in Read Mode 2.Read line by line 3.Search for comma 4.When Got comma Printf("\n"); 5.Problem is how I will return the buffer(Which is set of integers) to calling program reading the data values column wise???
You are lost. This is not a C question. You don't know what CSV means as
opposed to (and including) 'comma delimited' applied to file formats.
And 'comp.lang.c' is the wrong group for this. Maybe 'comp.programming'?
If you ask there, I and several others will offer our best advice.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein --- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: francis70 |
last post by:
Hi,
I have these 2 problem? Is there a way in Oracle to read UNCOMMITED
data. i.e. in Oracle the normal behaviour is that a user's updates to a
table are visible to other users ONLY when the...
|
by: Markus Breuer |
last post by:
I have a question about oracle commit and transactions. Following scenario:
Process A performs a single sql-INSERT into a table and commits the
transaction. Then he informs process B (ipc) to...
|
by: jas |
last post by:
Hi,
I would like to start a new process and be able to read/write from/to
it. I have tried things like...
import subprocess as sp
p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
|
by: phplasma |
last post by:
Hey,
I am currently attempting to implement a multi-threaded C# socket,
using SSL (.pem file/certification/private key combo) server using
Visual Studio C# Express.
I have successfully made...
|
by: chikhalepankaj |
last post by:
hi guys, I hv problem in reading data from text file. I want to read data in column wise from the table shown as below
Module Ad Di Do
4011 1 2 ...
|
by: arnuld |
last post by:
This works fine, I welcome any views/advices/coding-practices :)
/* C++ Primer - 4/e
*
* Exercise 8.9
* STATEMENT:
* write a program to store each line from a file into a
*...
|
by: zl2k |
last post by:
hi, there
I have a appendable binary file of complex data structure named
data.bin created by myself. It is written in the following format:
number of Data, Data array
Suppose I have...
|
by: Sachin Garg |
last post by:
I have a program which opens a fstream in binary input+output mode, creating
the file if it doesn't exists. But writing doesn't works after reading, it
must be something obvious that I am not aware...
|
by: pchaitanya |
last post by:
hi all,
suppose in a table if i have columns namely name,entrydate
now on retriving and binding to a gridview how can I get names rowwise and entrydate columnwise on a gridview
on...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |