I have a pretty good understanding of LaTex, but I've spent a while now digging up information on catcodes, but because they're lesser known, I haven't seen any applicable examples that will help with my problem.
For those of you familiar with any experimental work with data tables, you'll probably be aware that the standard way to store data as numbers in is a table, either tab or space delimited, with enters for a new line. This is how many data processing programs read and write data.
As a result, if I want to enter data into LaTex, I have to reformat my data table to include ampersands between columns and a double-backslash to end lines. Is there a straight forward way to create a new environment, which redefines spaces and tabs and double-backslashes, inserts a tabular environment, and then undoes the redefinitions so that they do not have any effect on the rest of the code, something like
\newenvironment{datatable}[2]
\catcode{10}=\catcode{4}
% catcode 10 is spaces and tabs, catcode 4 is an ampersand
\catcode{5}=\\ % catcode 5 is the return character
% I haven't a clue how to define it as a double-backslash
\begin{tabular}{#1}
\#2
\end{tabular}
% I have no idea how I would undo the definitions from above, because if I said
\catcode{10}=\catcode{10}
% I'm not sure it would make any sense
% catcode 10 already points to catcode 4
% and I haven't seen anyone use an undo command for catcodes yet
\catcode{10}=\catcode{4}
% catcode 10 is spaces and tabs, catcode 4 is an ampersand
\catcode{5}=\\
% catcode 5 is the return character, I haven't a clue how to define it
% as a double-backslash
\begin{tabular}{#1}
#2
\end{tabular}
% I have no idea how I would undo the definitions from above
% because if I said
\catcode{10}=\catcode{10}
% I'm not sure it would make any sense
% catcode 10 already points to catcode 4
% and I haven't seen anyone use an undo command for catcodes yet
Hopefully it's clear what I want to do, but effectively I just want to get a better understanding of redefining catcodes, and then undoing redefinitions. Hopefully this question also helps some other Tex users as well. Thanks for your help!
Edit:
The solution does not require the use of catcodes. In my case, I require the ability to implement the solution on overleaf.com (which is just an online latex editor and compiler), but other than that, I have no restrictions.



csvsimpleorpgfplotstableordatatoolpackages. – CarLaTeX Jan 20 '19 at 04:23