0
$\begingroup$

How can I shift the first element of a list by 148.38 and the second element by -38.45? The data

417864.69,5332858.39,0.00,3629.824,2,0,0,0.10
417864.94,5332858.82,0.00,3885.531,2,0,1,0.10
417865.19,5332859.25,0.00,3647.226,2,0,2,0.10
417865.44,5332859.69,0.00,-884.887,2,0,3,0.10
...
...

are imported via

w = Import["a.010.csv", "TSV"];

(by the way: the data are rounded if I use "CSV" - I don't know why ...)

$\endgroup$
0

1 Answer 1

3
$\begingroup$

You should read through the help docs on accessing list elements.

If your data is a list of lists in the following form

w = {{417864.69,5332858.39,0.00,3629.824,2,0,0,0.10},
     {417864.94,5332858.82,0.00,3885.531,2,0,1,0.10}}

Then you can use the short form of the Part and Span commands operate on elements like this:

w[[;;,1]] = w[[;;,1]] + 148.38;
w[[;;,2]] = w[[;;,2]] - 38.45;
AccountingForm@NumberForm[#, 10] & /@ w

which results in this output

{{418013.07,5332819.94,0.,3629.824,2,0,0,0.1}
 {418013.32,5332820.37,0.,3885.531,2,0,1,0.1}}
$\endgroup$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.