I have a follow-up question on https://tex.stackexchange.com/a/598981/46023
Everything works in the MWE there, but when used in my original example it no longer works (note: originaltable.csv is a greatly shortened version of the original, what comparisons, calculations, etc. are made of).
The umlaut 'ä' in the word 'Molybdän', as written in originaltable.csv, is the problem.
\begin{filecontents}[overwrite]{originaltable.csv}
Z; Symbol; Name
2; He; Helium
41; Mo; Molybdän
\end{filecontents}
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableread[col sep=semicolon, header=true]{originaltable.csv} {\psetable}
% Methode % https://tex.stackexchange.com/a/598981/46023
\makeatletter
\long\def\protected@iwrite#1#2#3{\begingroup%
#2%
\let\protect@unexpandable@protect%
\edef\reserved@a{\immediate\write#1{#3}}%
\reserved@a%
\endgroup%
\if@nobreak\ifvmode\nobreak\fi\fi}
\newcommand{\mywrite}[2]{\protected@iwrite#1{}{#2}}%
\makeatother
\begin{document}
\newwrite\out
\immediate\openout\out=out.csv
\foreach[count=\n from 0] \row in {0,1}{%%
% In:
\pgfplotstablegetelem{\row}{Z}\of{\psetable}
\xdef\Z{\pgfplotsretval}%
\pgfplotstablegetelem{\row}{Symbol}\of{\psetable}%
\xdef\Symbol{\pgfplotsretval}%
\pgfplotstablegetelem{\row}{Name}\of{\psetable}%
\xdef\Name{\pgfplotsretval}%
% Out:
\mywrite\out{\Z; \Symbol; \Name}% does not work :(
}%%
\immediate\closeout\out
%\input{out.csv}
% Target in:
\pgfplotstableread[col sep=semicolon, header=false]{out.csv}{\mytable}
\pgfplotstabletypeset[string type]{\mytable}
\end{document}

\xdef(again not a latex command so already broken all accent commands before you get to the write. – David Carlisle May 29 '21 at 06:59newritein your title is meant to benewwrite. (I can't submit an edit for just one character.) – LSpice May 29 '21 at 14:39