# Basic Question: how should I read this instruction?

I'm very new at using Mathematica and it's not my Job. It's just something I like.

data = MapAt[DateString[{#, {"Day", "/", "Month", "/", "Year"}}] &,
Import["D:\\Sheet 1.tsv"][[3 ;;, {1, 2}]]
, {All, 1}]


I have found out that DateString[{#, {"Day", "/", "Month", "/", "Year"}}] seems to be a function can I define it in a variable and reuse? It would be clearer for me.

Should I write f[x] := DateString[{#, {"Day", "/", "Month", "/", "Year"}}] ?

I'm a c# developer and we would call it "Refactor\Introduce a new variable". May I do the same also for Import["D:\Sheet 1.tsv"]? I guess I can but then what is [[3 ;;, {1, 2}]]?

• you can use ClearAll[f]; f[x] := DateString[{x, {"Day", "/", "Month", "/", "Year"}}]  or ClearAll[f]; f= DateString[{#, {"Day", "/", "Month", "/", "Year"}}]&;  – kglr Oct 27 '19 at 15:03
• What the & stands for? – Revious Oct 27 '19 at 15:04
• Revious, see Function (&) in the docs. – kglr Oct 27 '19 at 15:05
• @kglr: thanks, do you know also where I can find the documentation to understand this piece of code: [[3 ;;, {1, 2}]]? – Revious Oct 27 '19 at 15:06
• try Part and Span (;;). In general, highlight the [[ or ]] and hit F1 to get the related documentation page. Similarly, highlight ;; and hit F1, highlight & and hit F1 etc. – kglr Oct 27 '19 at 15:18

You can define the function f in several ways

ClearAll[f];
f[x_] := DateString[{x, {"Day", "/", "Month", "/", "Year"}}]


or

ClearAll[f];
f = DateString[{#, {"Day", "/", "Month", "/", "Year"}}]&


or

ClearAll[f];
f = Function[DateString[{#, {"Day", "/", "Month", "/", "Year"}}]]


imp = Import["D:\\Sheet 1.tsv"];


Take rows from the third row to the last (3;;) and columns 1 and 2 ({1,2}) from imp:

data = imp[[3 ;;, {1, 2}]];


Map f on entries in column 1:

data = MapAt[f, data, {All, 1}]


• aren't you missing the pattern underscore for the argument to f? I think that should be f[x_]:=... – Albert Retey Oct 30 '19 at 22:09