Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

CSV Data Manipulation 2

Status
Not open for further replies.

BryceCESL

Mechanical
Aug 28, 2017
2
0
0
NZ
Could someone suggest how I can manipulate a cell in a csv file which contains 4 sets of values from a GCDC X16-4 accelerometer Time,Ax,Ay,Az and divide only the Ax,Ay,Az values by 2048 and then keep the output format the same with the Time,Ax,Ay,Az within the one cell.
 
Replies continue below

Recommended for you

Try tek-tips...

Dan - Owner
URL]
 
how I can manipulate a cell in a csv file

.csv TEXT files do NOT have cells.

I fail to understand.

If, however, you are using Excel to open a .csv TEXT file, which is really a bad idea (just because you CAN hit your thumb with a hammer, does not mean that you SHOULD) I'd suggest posting your question at Eng-Tips sister site, where Excel questions like this can be addressed.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
".csv TEXT files do NOT have cells"

When read by Excel, they map directly into Excel's cell structure, so the 4th CSV values on each line will wind up in column D.

What I would do is
> read the file into Excel
> type 2048 somewhere away from the 4 columns
> do a Copy of the 2048 cell
> Paste Special/Divide columns B,C, and D
> delete the 2048 value
> save as a CSV

If necessary, these operations can codified in a macro

TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529 Entire Forum list
 
@IRstuff,

A text file has no cells. And as I stated, if the OP were opening the text file with Excel, it is a very bad idea to do so. Excel can and will change data unless you protect your data be taking charge of the conversion. That is why one should IMPORT data into an existing workbook/worksheet, using the parsing and converstion features in the Import dialog.

Unintended converstions that could happen if a text file is opened with Excel:
[pre]
1/2 Becomes Date Jan 2 of current year
1:2 Becomes Time 1:02:00
12E3 Becomes 12,000
01234 Becomes 1234
[/pre]

However, by using the Data > Get External Data > From Text... using a delimited import with COMMA as delimiter and specifying the appropriate Column Data Format, these conversions can be avoided.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Yes it does, BUT you might not get the results you expect when your data is changed on open if you ever have data similar to the examples I posted.

Just because you can does not mean that you should.

I rarely open a text file with Excel for this very reason. I IMPORT. Since most of my work was in a production environment, IMPORT, once established, can simply be refreshed to import fresh data, retaining all the data conversion protection previously applied.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.
Back
Top