Copy data at specified location from multiple files


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Copy data at specified location from multiple files

Hello everyone, Im super new to coding but increasingly in need of it at work. Im have task stacked because of this problems, that I cannot figure out how to solve looking on the internet after trying many many things that looked similar to me.
I have multiple data files of the form (see below).
My question is how can I copy the two columns with the size and rotation data, which is the only one that I need from the file. And then how to do that for several (1000) data files like this.
Thank you very much in advance
Code:
text text       text text text
text texttexttexttext     texttexttext
text text text text text text
X=size
Y_rotation
   45.000000    87.611985 
   47.812500    85.219808 
   42.187500    85.219808 
   45.000000    82.819244 
   50.625000    82.819244 
other text other text  other text
other text

Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

Please use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the icon that currently looks like </> in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Thank You.

Last edited by Don Cragun; 01-11-2019 at 08:40 PM.. Reason: Add CODE tags and moderator's note.
# 2  
Quote:
Originally Posted by Xfiles_fan
Hello everyone, Im super new to coding but increasingly in need of it at work. Im have task stacked because of this problems, that I cannot figure out how to solve looking on the internet after trying many many things that looked similar to me.
I have multiple data files of the form (see below).
My question is how can I copy the two columns with the size and rotation data, which is the only one that I need from the file. And then how to do that for several (1000) data files like this.
Thank you very much in advance
Code:
text text       text text text
text texttexttexttext     texttexttext
text text text text text text
X=size
Y_rotation
   45.000000    87.611985 
   47.812500    85.219808 
   42.187500    85.219808 
   45.000000    82.819244 
   50.625000    82.819244 
other text other text  other text
other text

Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

Please use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the icon that currently looks like </> in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Thank You.
Hi Xfiles_fan,
Welcome to the UNIX.com forums.

When starting a new thread here, please always tell us what operating system and shell you're using. Various utilities behave differently are different BSD-, Linux-, and UNIX-systems and various shells provide features that do not appear in all shells. If we don't know what environment you're working in, we are likely to make suggestions that work fine for some of us, but won't work in your environment.

Please show us in (Code tags) what you have tried and explain what parts of that worked for you and what parts fell short.

Are the lines that you have shown us in your example:
Code:
X=size
Y_rotation

literal text, or is the X= literal text and the size a place holder for a numeric string. And, is it really an underscore character in Y_rotation or should it also be an equals sign? And is the rotation literal text or a place holder for another numeric string.

Could either of those lines appear elsewhere in what you have shown in your example as text and othertext? Could lines you have shown as text in your example ever start (possibly following leading spaces or tabs) with a numeric character?

Exactly what output are you hoping to produce from the example you have shown us?

Can multiple occurrences of the tabular data you have shown us appear in a single file? If so, how should that affect the output you want?
These 2 Users Gave Thanks to Don Cragun For This Post:
# 3  
Quote:
Originally Posted by Xfiles_fan
Hello everyone, Im super new to coding but increasingly in need of it at work. Im have task stacked because of this problems, that I cannot figure out how to solve looking on the internet after trying many many things that looked similar to me.
I have multiple data files of the form (see below).
My question is how can I copy the two columns with the size and rotation data, which is the only one that I need from the file. And then how to do that for several (1000) data files like this.
Thank you very much in advance
Code:
text text       text text text
text texttexttexttext     texttexttext
text text text text text text
X=size
Y_rotation
   45.000000    87.611985 
   47.812500    85.219808 
   42.187500    85.219808 
   45.000000    82.819244 
   50.625000    82.819244 
other text other text  other text
other text

Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

Please use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the icon that currently looks like </> in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Thank You.

Hi,

What you need is a parser. I doubt you can find one that answers exactly your need because we have not a universal parser and every one has a particular data file format.
So, in a first time, you must write a parser for one file, than you can make it process all the files in a directory.
Parsing, in this case, is basicaly, String processing, you will your file line after another until the begining of data and stop when the data end.
Very difficult to talk about it without specifying additional informations about the file or the programing language.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Read multiple text files and copy data to csv
lp.descamps
hi i need to extract lines from multiple files to a csv file. for example, i have these 3 files file1.txt date:29dec1980 caller:91245824255 called:8127766 file2.txt date:11apr2014 caller:9155584558 called:8115478 file3.txt date:25jun2015 caller:445225552 called:8117485... Shell Programming and Scripting
30
Shell Programming and Scripting
How to copy files from one location to another using xargs??
Saidul
Hello Experts, I need to copy files from one location to another using xargs. Tried something like this (In Ubuntu & Solaris ). mkdir -p 1234; find /home/emd/Desktop/n007/M007/ -type f -name "A2014*" | xargs -0 cp -r {} /home/emd/Desktop/1234 But every time i run this, a weird error...... Shell Programming and Scripting
6
Shell Programming and Scripting
Copy files from one location to another
Saidul
I have below files in one location /test/files and also for each dates there are similar files A20130924.0000-0005_file1 A20130924.0000-0005_file2 A20130924.0005-0010_file1 A20130924.0005-0010_file2 . . . A20130924.2355-0000_file1 A20130924.2355-0000_file2 If i execute the script like...... Shell Programming and Scripting
4
Shell Programming and Scripting
Shell Script for Copy files from one location to another location
allways4u21
Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval.... Shell Programming and Scripting
2
Shell Programming and Scripting
copy files from one location to similar location
pharos467
I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub...... UNIX for Advanced & Expert Users
1
UNIX for Advanced & Expert Users