How to read data from a text file based on the title?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to read data from a text file based on the title?

Liaket
I have two text files, sample01.txt and sample02.txt. I want to read those two text files and make new text file Composed_matrix_sample01_sample02. Please find all three file as attached. 

I solved this problem using MATLAB. A Matlab solution is also attached. I want to convert the MATLAB code into Octave code.  (I made some part of it compatible to Octave).

--
    
Mohammed Liaket Ali

Research Assistant
Chair of Technical thermodynamics / Thermal combustion Technology,
Brandenburgische Technische Universität Cottbus-Senftenberg.

Technology & Research Centre   +49 176 47166964
Burger Chaussee 25                   [hidden email]
03044 Cottbus, Germany             



sample02.txt (1K) Download Attachment
Composed_matrix_sample01_sample02.png (46K) Download Attachment
sample02.png (47K) Download Attachment
sample01.png (61K) Download Attachment
sample01.txt (1K) Download Attachment
MATLAB_code.m (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

Francesco Potortì
>I have two text files, *sample01.txt* and *sample02.txt. *I want to read
>those two text files and make new text file
>*Composed_matrix_sample01_sample02*. Please find all three file as
>attached.

Mohammed,

please attach the text files, rather than a screenshot of the files.

--
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it



Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

nrjank
In reply to this post by Liaket
On Wed, Feb 13, 2019 at 10:00 AM Mohammed Atta <[hidden email]> wrote:
I have two text files, sample01.txt and sample02.txt. I want to read those two text files and make new text file Composed_matrix_sample01_sample02. Please find all three file as attached. 

I solved this problem using MATLAB. A Matlab solution is also attached. I want to convert the MATLAB code into Octave code.  (I made some part of it compatible to Octave).

did you try running the code in octave?   did you get errors? what were the error messages?

looking at the MATLAB_code file, the first line after which you say the problem starts uses splitapply.  the error message should be something like

warning: the 'splitapply' function is not yet implemented in Octave
Please read <https://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'splitapply' undefined near line 1 column 1

that should be pretty self explanatory


So the real question is:  without us deciphering your files and guessing, what do you want to do?  Octave can read and write data in text files. can you give a very small example of the text you want brought in, what you want done to it, and what you want it to look like when you export it?


Reply | Threaded
Open this post in threaded view
|

Fwd: How to read data from a text file based on the title?

nrjank
Please keep the help list copied on all emails. The convention of this list is also to trim reply text and bottom post (this paragraph is top posting)

On Thu, Feb 14, 2019, 03:23 Mohammed Atta <[hidden email] wrote:
In the first "sample01.txt" there are two columns. One is for T[K] and another one is for mole concentration. In "sample01.txt" data for 3 species are piled vertically.
On the other file "sample02.txt" all the columns are arranged side by side with only one T[K] column which is common for all the species.
The third file (Composed_matrix_sample01_sample02.png) shows how I want to merge data from two files. If there are three species (in "sample01.txt") i want three matrix like the sample that i gave in Composed_matrix_sample01_sample02.png.

It is easy to do it in MATLAB. If you want i can provide a more comprehensive explanatory code for MATLAB.

Here, I such a solution.



What I was hoping for was a minimal example that just highlighted the problem area. You're code fails at splitapply because Octave does not have that function. The behavior can probably be emulated using some other functions. But right now we'd have to walk through all of your code to see what you're actually doing at that step, and then guess at why. 



Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

nrjank
Please Reply All to keep the help list copied on the conversation so everyone can contrubute. Copied below again as a courtesy to the group.

On Thu, Feb 14, 2019, 6:37 AM Mohammed Atta <[hidden email]> wrote:
I want to split the sample01.txt file to extract the sub table in the  form of matrix, so that it can be merged with the data from another text file. So i am not finding a way how to do it. This is done by "splitapply"
 in MATLAB. In Octave how can I implement such action?




Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

Doug Stewart-4


On Thu, Feb 14, 2019 at 6:46 AM Nicholas Jankowski <[hidden email]> wrote:
Please Reply All to keep the help list copied on the conversation so everyone can contrubute. Copied below again as a courtesy to the group.

On Thu, Feb 14, 2019, 6:37 AM Mohammed Atta <[hidden email]> wrote:
I want to split the sample01.txt file to extract the sub table in the  form of matrix, so that it can be merged with the data from another text file. So i am not finding a way how to do it. This is done by "splitapply"
 in MATLAB. In Octave how can I implement such action?




Let me review the situation.
Questions as to how octave works and how to use a function will be answered.
Guidance as to how to do something in octave. ( what functions to use) will be answered.

But now you are asking us to write your software for you.
How much will you pay me to do it?


--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

Liaket
I shared my MATLAB code with proper explanation in the sense, that it will help others and make the problem much easier. In further emails I stated my problems which I am encountering in Octave while executing the same procedure that i did in MATLAB. 
However, If helping someone to extract certain format of text file data means "WRITING SOMEONE ELSE SOFTWARE" then, this thread is no longer useful. 

Thanks everyone for your valuable time.

On Thu, Feb 14, 2019 at 1:53 PM Doug Stewart <[hidden email]> wrote:


On Thu, Feb 14, 2019 at 6:46 AM Nicholas Jankowski <[hidden email]> wrote:
Please Reply All to keep the help list copied on the conversation so everyone can contrubute. Copied below again as a courtesy to the group.

On Thu, Feb 14, 2019, 6:37 AM Mohammed Atta <[hidden email]> wrote:
I want to split the sample01.txt file to extract the sub table in the  form of matrix, so that it can be merged with the data from another text file. So i am not finding a way how to do it. This is done by "splitapply"
 in MATLAB. In Octave how can I implement such action?




Let me review the situation.
Questions as to how octave works and how to use a function will be answered.
Guidance as to how to do something in octave. ( what functions to use) will be answered.

But now you are asking us to write your software for you.
How much will you pay me to do it?


--
DASCertificate for 206392



--
    
Mohammed Liaket Ali

Research Assistant
Chair of Technical thermodynamics / Thermal combustion Technology,
Brandenburgische Technische Universität Cottbus-Senftenberg.

Technology & Research Centre   +49 176 47166964
Burger Chaussee 25                   [hidden email]
03044 Cottbus, Germany             


Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

nrjank
On Thu, Feb 14, 2019 at 8:07 AM Mohammed Atta <[hidden email]> wrote:
I shared my MATLAB code with proper explanation in the sense, that it will help others and make the problem much easier. In further emails I stated my problems which I am encountering in Octave while executing the same procedure that i did in MATLAB. 
However, If helping someone to extract certain format of text file data means "WRITING SOMEONE ELSE SOFTWARE" then, this thread is no longer useful. 

Thanks everyone for your valuable time.


Thank you for replying to everyone this time.  Again, the convention of this list is to trim extraneous text and bottom post.   See: http://www.idallen.com/topposting.html

Now, you are bringing in two text files of nicely tabulated, delimited data, mostly numerical but with text headers, and want to export a delimited data file with the data rearranged.  I pointed out that if you can replace 'splitapply', which is really a wrapper matlab uses to combine multiple lower level functions, it seems the rest of the process should work.  That said, you have a fairly involved process for handling and massaging all of this data. my usual approach is to do a dlmread of the files, assign columns to variables, and then work with them that way to manipulate and rearrage the data, construct a new variable with the data in the order I want, and then do a dlmwrite to output the revised text file.  If I have time to step through all of your code, I might look at whether or not this is manageable.  maybe if you want special header handling, you'll need something a bit more involved to handle multiple types of data (text labels, numeric data, etc.), but I've rarely needed to do much more that basic file I/o and array concatenation to make things like this work.

what are you doing with the split array, and maybe we can suggest a few substitute commands to produce the same effect. help us help you with a Minimal Working Example:  https://en.wikipedia.org/wiki/Minimal_working_example

nickj


Reply | Threaded
Open this post in threaded view
|

Re: How to read data from a text file based on the title?

karl
In reply to this post by Liaket
Am 13.02.19 um 15:53 schrieb Mohammed Atta:
I have two text files, sample01.txt and sample02.txt. I want to read those two text files and make new text file Composed_matrix_sample01_sample02. Please find all three file as attached. 

I solved this problem using MATLAB. A Matlab solution is also attached. I want to convert the MATLAB code into Octave code.  (I made some part of it compatible to Octave).

--
    
Mohammed Liaket Ali

Research Assistant
Chair of Technical thermodynamics / Thermal combustion Technology,
Brandenburgische Technische Universität Cottbus-Senftenberg.

Technology & Research Centre   +49 176 47166964
Burger Chaussee 25                   [hidden email]
03044 Cottbus, Germany             


    

May I congratulate to your excellent choice of your online pseudonym!