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 7611
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*********@ya hoo.co.in> wrote in message
news:81******** *************** ***@posting.goo gle.com... 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.programmi ng'?
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 user commits. But in
Informix there is this thing called ISOLATION LEVELS. For example by
setting the ISOLATION LEVEL to DIRTY READ, a user will read dirty data,
i.e. the last uncommited updated value of a field by some other user. Is
|
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 read the new date. So
process B starts "select ..." but does not get the previously inserted
row. The timespan between commit and select is very short.
(NOTE: two different sessions are used)
Questions:
1.) Does commit when returning from call...
|
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)
p.stdin.write("hostname\n")
however, it doesn't seem to work. I think the cmd.exe is catching it.
|
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 the client application establish a connection,
and send data, which appears in plain, de-crypted text on the server -
this works.
|
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 -
4012 2 3 2
4013 2 3 3
4014 4 7 8
i m looking for a program which is going to read MODULE column and store it in a Char *Buf for eg.
| |
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
* vector<string>. Now, use istringstream to read read each line
* from the vector a word at a time.
|
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 following data.bin (3 Data appended to 2 Data):
2, data0, data1, 3, data0, data1, data2
|
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 of.
f.open(filename,ios::in | ios::out | ios::binary | ios::trunc)
The program flow is
1) write some data
2) read the data
|
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 Xaxis I want entrydate and yaxis names
in following format
-----------------------------------------------------------------------------------
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |