<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="https://www.schweda.net/style_feed.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:atom="http://www.w3.org/2005/Atom"	
	xmlns:dc="http://purl.org/dc/elements/1.1/" > 
<channel>
    <title>schweda.net - Blog</title>
    <link>https://www.schweda.net/</link>
    <description>schweda.net - Blog - Blog-Beitraege</description>
    <language>de-at</language>
    <copyright>Copyright 2006-2026</copyright>
    <generator>schweda.net</generator>
    <managingEditor>heinz.schweda@schweda.net (Heinz Schweda)</managingEditor>
    <webMaster>heinz.schweda@schweda.net (Heinz Schweda)</webMaster>
    <category>Blog</category>
	<atom:link href="https://schweda.net/blog_rss.php?bid=573" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[CSV-Datei in Dynamics AX importieren/einlesen]]></title>
<description><![CDATA[
<p>MIt Hilfe der <strong>CommaTextIo</strong>-Klasse kann man CSV-Dateien in Dynamics AX einlesen. Der hier gezeigte Job zeigt ein einfaches Beispiel f&uuml;r die Verwendung dieser Klasse.
</p>


<pre class="pre_blog_axcode">
static void importCSVFile(Args _args)
{
    Filename fileName = @&quot;c:	empcsvimport.csv&quot;;
    CommaTextIo commaTextIo = new CommaTextIo(fileName, &quot;r&quot;);
    container lineCon;

    commaTextIo.inFieldDelimiter(&#39;;&#39;);
    commaTextIo.inRecordDelimiter(&#39; &#39;);
    while (commaTextIo.status() == IO_Status::OK)
    {
        lineCon = commaTextIo.read();

        info(strFmt(&quot;%1 %2 %3&quot;, conPeek(lineCon, 1), conPeek(lineCon, 2), conPeek(lineCon, 3)));
    }
}
</pre>


<p>Prinzipiell ginge dies auch genauso mit der <strong>TextIo</strong>-Klasse (oder <strong>AsciiIo</strong>), allerdings muss man dabei beachten, da&szlig; diese Klassen beispielsweise unerwartete Ergebnisse liefern k&ouml;nnen, wenn der <em>inFieldDelimiter </em>- in meinem Beispiel ein Strichpunkt - innerhalb eines Textes vorkommt.
</p>


<p>&nbsp;
</p>


<p>Folgende&nbsp;Beispieldatei w&uuml;rde anders verarbeitet, als vielleicht vom Entwickler erwartet. Die dritte Spalte in der dritten Zeile w&uuml;rde von der <em>read()</em>-Methode als zwei Spalten interpretiert werden.
</p>


<pre class="pre_blog_axcode">
100;450,00;Customername1
101;1200,00;Customername2
102;50,28;&quot;Customername 3; Second customername&quot;
</pre>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Thu, 02 Jul 2015 18:21:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=573</link>
<comments>https://www.schweda.net/blog_ax.php?bid=573</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=573</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=573</wfw:commentRss>
</item>
</channel>
</rss>	
