Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #98781

Re: Program to create csv file and write into it

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Program to create csv file and write into it
Date 2016-12-11 11:39 +0000
Organization A noiseless patient Spider
Message-ID <87shpuzoch.fsf@bsb.me.uk> (permalink)
References <6b201709-fae0-4a06-9783-af485e4040bf@googlegroups.com> <87wpf71pp6.fsf@bsb.me.uk> <08c753c8-4a52-4c95-9d33-15647011cbcf@googlegroups.com>

Show all headers | View raw


Alla _ <modelling.data@gmail.com> writes:
<snip>
> Oh, great ))) I am still far off with my assumptions. 
>
> (1) Yes, I have not repeated my goal here; I should have.
> I am planning to:
> # take a few excel spreadsheets, which contain financial statements;
> convert them into csv format

OK.  This part is not in C right?

> # read data from those csv files using C language

OK.

> # process that data (a few functions) to compute pro forma financial
> statements, and, if I find that to be not big enough,

OK, stop!  For my sake, take a simple goal and run with it.  Can you
show me one of these pro forma financial statements?  You know what you
mean, but it would help keep things concrete if I knew what the output
might be like.

<snip>
> Therefore, the program I have posted here is supposed to be one of the 
> functions, which will later on take already computed pro forma data and
> write it into a csv file.

Here I get lost.  I don't see any connection between what you posted and
the goals above.  You posted a program that reads data interactively and
writes that date to a binary file in some rather odd format.  I realise
that that is probably just a mistake, but I can't know from the code
what you really planned to to.

> There will be no stdin input, like the one I have 
> in this program (I took the main program's frame from D&D, as discussed
> elsewhere), but the initial data will also come from csv file, as also being
> discussed in another thread.

So the posted program was a trial of some sort?  I see.  Do you want to
get it working before moving on?  If so, you need to describe the intent
of that trial program and we can forget (for the moment) the goals you've
set yourself above.

> (2) no, I don't see any nulls, but I see huge unexpected white spaces in 
> the part I copied from a file with csv extension (as I see not csv yet); 
> I assume these white spaces  = nulls. 
> Please, help me to understand (I know I have been told the same thing in 
> my previous post, but I didn't understand it): do these nulls come
> from ...

The nulls come from that fact that you use fseek.  When you skip to a
fixed position in an output file, any data not explicitly written gets
set to 0.  If you write 'a', then fseek(fp, 3) and write 'b' before
closing the file you will get 'a' '\0' '\0' 'b' in the file (i.e. four
bytes, two of them nulls).

If you want to write this sort of file (and at the moment I don't see
why you do) you need a way to see exactly what is in a file.  Keith gave
you some pointers.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-10 09:30 -0800
  Re: Program to create csv file and write into it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-10 20:42 +0000
    Re: Program to create csv file and write into it Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-12-10 15:56 -0500
      Re: Program to create csv file and write into it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-10 21:08 +0000
    Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-10 23:48 -0800
      Re: Program to create csv file and write into it Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-11 00:01 -0800
      Re: Program to create csv file and write into it Keith Thompson <kst-u@mib.org> - 2016-12-11 01:12 -0800
      Re: Program to create csv file and write into it Keith Thompson <kst-u@mib.org> - 2016-12-11 01:27 -0800
        Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-11 04:50 -0800
          Re: Program to create csv file and write into it Barry Schwarz <schwarzb@dqel.com> - 2016-12-11 09:42 -0800
            Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 00:13 -0800
              Re: Program to create csv file and write into it Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 08:34 +0000
                Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 00:50 -0800
                Re: Program to create csv file and write into it Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 09:02 +0000
                Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 02:52 -0800
                Re: Program to create csv file and write into it Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 10:59 +0000
                Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 03:23 -0800
          Re: Program to create csv file and write into it mx2927 <mx2927@gmail.com> - 2016-12-11 20:44 +0100
            Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-11 23:57 -0800
              Re: Program to create csv file and write into it Barry Schwarz <schwarzb@dqel.com> - 2016-12-12 01:06 -0800
      Re: Program to create csv file and write into it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-11 11:39 +0000
        Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-11 04:47 -0800
          Re: Program to create csv file and write into it Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-11 14:43 +0000
            Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 00:56 -0800
      Re: Program to create csv file and write into it Barry Schwarz <schwarzb@dqel.com> - 2016-12-11 09:38 -0800
        Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 00:44 -0800
          Re: Program to create csv file and write into it Richard Heathfield <rjh@cpax.org.uk> - 2016-12-12 08:48 +0000
          Re: Program to create csv file and write into it Barry Schwarz <schwarzb@dqel.com> - 2016-12-12 01:19 -0800
            Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-12 02:30 -0800
            Re: Program to create csv file and write into it Manfred <noname@invalid.add> - 2016-12-12 15:10 +0100
              Re: Program to create csv file and write into it Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-12 12:35 -0800
  Re: Program to create csv file and write into it Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-10 14:29 -0800
    Re: Program to create csv file and write into it Alla _ <modelling.data@gmail.com> - 2016-12-10 23:57 -0800
      Re: Program to create csv file and write into it Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-11 00:33 -0800
        Re: Program to create csv file and write into it Keith Thompson <kst-u@mib.org> - 2016-12-11 01:19 -0800

csiph-web