0

Following my previous question: this is what i came up with: perf_data is a vector.

void read_data() {
    long val;
    ifstream infile1("/foo/other");

    infile1 >> val;
    perf_data[1].first = val;
    infile1.close();

    ifstream infile2("/foo/core_0");

    infile2 >> val;
    perf_data[0].first = val;
    infile2.close();
}

In python as I understand, this cannot be done for a file or can it be?

Community
  • 1
  • 1
rnish
  • 165
  • 1
  • 4
  • 11
  • Where did you get the 'understanding' that this cannot be done in python?! – us2012 Feb 09 '13 at 04:50
  • I need to read it line by line and then append it to the `perf_data` assuming, perf_data is a collection or array. Pls correct me if i am wrong. – rnish Feb 09 '13 at 04:53
  • And what's wrong with python's `myfile.readline()`? – us2012 Feb 09 '13 at 04:55
  • that's lack of knowledge! – rnish Feb 09 '13 at 05:00
  • 1
    @rnish: The description in the comment and the code in C++ don't quite go together. The code is reading a single value from each one of the two files using it to update an existing value in an array and then you close the files. There is no *line by line* and there is no *appending*. – David Rodríguez - dribeas Feb 09 '13 at 05:01
  • Sure. this is a simplified case of it :-) – rnish Feb 09 '13 at 05:07
  • Can you be more succinct in your question as it seems unfair for people to have to read your previous post and then some C++ code to be asked ``... this can't be done or can it ...`` - Are you sill wanting to tail a CSV file as it's updated? – sotapme Feb 09 '13 at 14:59
  • @sotapme: thank you. But I would implement it in python. using the suggestion `us2012` gave me. :-) – rnish Feb 10 '13 at 01:59
  • Well if ``myfile.readline()`` is the answer then I'm still unsure of the question :/ – sotapme Feb 10 '13 at 11:03

0 Answers0