# Reading a CSV text file

**URL:** <https://forum.dynamobim.com/t/reading-a-csv-text-file/113127>\
**Category:** Uncategorized\
**Created:** [November 19, 2025, 5:49pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127 "2025-11-19T17:49:39Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 19, 2025, 5:49pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/1 "2025-11-19T17:49:39Z")

</div>

```auto
Reading a CSV text file

An element consisting of many lines

is truncated.

Is there a way to read the entire file?

See images.
Thanks

```

 ![lettura2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/2/b264a31f3af7d65425608137300212d7b24c60f7.jpeg)

 ![lettura1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/583efb20a79adfd1dba1d3fa9a03ec34580e48c9.jpeg)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 19, 2025, 7:03pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/2 "2025-11-19T19:03:59Z")

</div>

First up: That isn’t a [CSV](https://en.wikipedia.org/wiki/Comma-separated_values). It’s almost an [XML](https://en.wikipedia.org/wiki/XML), but not quite as it appears to have been edited (a real XML should have a valid header and indentation would align). You’re setting yourself up for LOTS of issues by using the wrong format for your reading method.

If you want to avoid the XML and just read the text, try File.ReadText and then String.Split where you use the new line character (`"\r"`, `"\n"`, or `"\r\n"` depending on how your file is formatted).

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 19, 2025, 11:07pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/3 "2025-11-19T23:07:00Z")

</div>

Just a thought, you could try importing the data into Excel as xml and then use the saved .xlsx file to import the data as a list?

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 20, 2025, 5:59pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/4 "2025-11-20T17:59:11Z")

</div>

> [@jacob.small](#):
>
> File.ReadText

```auto
Thanks for the reply.

The 

File.ReadText

command works well, but the problem is the file reading time... even an hour...

The CSV command skips long elements, but reads the file in a minute.

I don't know how to do this.

Regards

```

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 20, 2025, 6:00pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/5 "2025-11-20T18:00:18Z")

</div>

```auto
Thanks for your reply.

I wouldn't use Excel for this problem.

Regards

```

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [November 21, 2025, 12:28am UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/6 "2025-11-21T00:28:14Z")

</div>

better still- use the XML specific Dynamo nodes

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 21, 2025, 9:17am UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/7 "2025-11-21T09:17:51Z")

</div>

> [@Andrew\_Hannell](#):
>
> XML specific Dynamo nodes

```auto
Thanks for the reply.

If I switch to Excel, I lose the formatting; the spaces are deleted.

```

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 21, 2025, 9:18am UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/8 "2025-11-21T09:18:21Z")

</div>

```auto
Thanks for the reply.

If I switch to Excel, I lose the formatting; the spaces are deleted.

```

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [November 21, 2025, 3:59pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/9 "2025-11-21T15:59:44Z")

</div>

Hi,

a solution with `xml.etree`

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3a9212e7d8a9f23add248f2c63c294ed653053b.png)

```python
import sys
import clr
import System

import xml.etree.ElementTree as ET

out = []
path_xml = IN[0]

with open(path_xml, 'r', encoding='utf-8') as f:
    txt = f.read()
        
root = ET.fromstring(txt)    
#xmlBefore = ET.tostring(root)
item = root.find('DesEstesa')
if item is not None:
    OUT = item.text,

```

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 21, 2025, 4:31pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/10 "2025-11-21T16:31:11Z")

</div>

Grazie ….. lo provo….. Ma il prezzo è del prezziario PAT …. trentino?

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [November 22, 2025, 5:30am UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/11 "2025-11-22T05:30:57Z")

</div>

can you post the unedited data file (or a sample with the same structure)  
It looks like some kind of estimating data?

As @jacob.small comments- it should include header etc

---

<div class="post-metadata">

**Author:** ![ingalvolt](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ingalvolt](https://forum.dynamobim.com/u/ingalvolt)\
**Post date:** [November 22, 2025, 7:46am UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/12 "2025-11-22T07:46:06Z")

</div>

```auto
Thanks for your reply.

The data file is very long and contains entries with many lines... it has a size of...

If I reduce it significantly, the file reads correctly.

But if I keep it in its entirety, the reading takes a very long time and never finishes.

I attach a voice that repeats itself many times

This is the last entry....the entire file has 468500 lines

```

 ![voce](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/f/cff754aab86d00f568e675f521cf91396afb0c84.jpeg)

```auto

```

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 22, 2025, 1:40pm UTC](https://forum.dynamobim.com/t/reading-a-csv-text-file/113127/13 "2025-11-22T13:40:01Z")

</div>

The number of lines isn’t a problem. The method you’re using to access it is.

A XML (not Excel) based methods would be best here, but as you aren’t sharing a dataset or the complex context of what you want to do after you read in the data, and as such no one can help you any more than repeating what has already been said.
