# LREAL PLC data type in Ignition

**URL:** <https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793>\
**Category:** Ignition\
**Created:** [December 19, 2022, 4:50pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793 "2022-12-19T16:50:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 4:50pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/1 "2022-12-19T16:50:44Z")

</div>

I have a LREAL in a PLC connected to a tag in Ignition. I have this tag in ignition set as a DOUBLE thinking this data type allows the most numbers. When viewing the tag in the tag browser I see the tag correctly showing the full value (eg. 1000000028920.2305). However I want to copy this value to a csv file and with the number being so big it shows it as "1.0000000289202305E12". What can I do to show this entire value without having it convert to an exponent? Is there formatting I can do in the tag script when pulling the value or am I using the wrong data type?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 19, 2022, 5:04pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/2 "2022-12-19T17:04:13Z")

</div>

> [@michael.black](#):
>
> However I want to copy this value to a csv file and with the number being so big it shows it as "1.0000000289202305E12

Technically this is the correct number. Where are you viewing this value? This sounds less like an Ignition issue and more like a third party software configuration issue.

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/3 "2022-12-19T17:09:56Z")

</div>

Correct, it is the right number. I have a script which simply reads in this value and then once a day I create a csv file with this value in it. It is showing as with the exponential part in it instead of showing me the entire 'real' value with a decimal place. I just created a simple label in my project and without applying a format transform to it it comes up with the exponential part. If I do the format transform which transform it into a number I then see the entire value. This entire value is what I want to display in my csv file, not the exponential value.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 19, 2022, 5:15pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/4 "2022-12-19T17:15:18Z")

</div>

As long as you're not doing anything to change the value, I would expect it to work.

Can you show the script that you're using to read the value?

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 5:19pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/5 "2022-12-19T17:19:04Z")

</div>

```auto
def create_totalizer_csv():
	"""Create flow totalizer csv file with current values at time of csv file creation
	
	Params:
		none
	
	Returns:
		none
	"""

	#establish logger
	logger = system.util.getLogger("Totalizer CSV file")

	##dynamically create list of flow totalizer tag paths including filter to only look at UDT instance tags and AI inputs with FT
	path = '[PLC]AnalogInputs'
	fltr = {'tagType': "UdtInstance", 'name': "*FT*"}
	tags = system.tag.browse(path,fltr)

	#get current time and format
	today = system.date.now()
	formattedTime = system.date.format(today,"MM-dd-yyyy HH:mm")

	#create custom header row
	headerTagPaths = [str(tag['fullPath']) + "/DeviceName" for tag in tags]
	  #reads in device names and creates array for header. Inserts DATE/TIME header in first index position
	headers = ['DATE/TIME'] + [(str(header.value) + ' in CFT') for header in system.tag.readAll(headerTagPaths)]

	#populate flow totalizer data
	dataTagPaths = [str(tag['fullPath']) + "/TotalizerValue" for tag in tags]
	  #read in tag values and create array for data. Inserts formatted time in first index position
	totalizers = [str(formattedTime)] + [data.value for data in system.tag.readAll(dataTagPaths)]

	#convert to dataset
	Totdataset = system.dataset.toDataSet(headers, [totalizers])
	
	#write dataset to dataset tag
	TotalizerdatasetTag = '[PLC]TotalizerCSV'
	system.tag.writeBlocking(TotalizerdatasetTag, Totdataset)
	logger.info("Data written to dataset tag")

	#convert dataset to csv file
	csv = system.dataset.toCSV(dataset = Totdataset, showHeaders = True)
	html = system.dataset.dataSetToHTML(True, Totdataset, 'Totalizer Values:')
	
	#define file path and populate file
	filePath = "C:\\DailyCSVFiles\\totalizer.csv"
	system.file.writeFile(filePath, csv)

	if system.file.fileExists("C:\\DailyCSVFiles\\totalizer.csv"):
		logger.info("File written to csv")
	else:
		logger.info("File does not exist!")

```

The line reading in the value is totalizers=

I also just created another tag within my UDT as a string and it simply takes the TotalizerValue and converts it to a string. This string value is showing up as an exponential value. This value is the same as I am seeing in my csv file.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 19, 2022, 5:39pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/6 "2022-12-19T17:39:42Z")

</div>

A couple of things:

1. formattedTime is already a String, so you shouldn't need to cast it to a string.
2. `system.tag.readAll()` has been deprecated, you should be using `system.tag.readBlocking()`  
(NOTE: `system.tag.readAll()` still works, and I wouldn't expected it to stop anytime soon, but it's best practice not to use deprecated methods)

If after you generate the list of totalizers you print the list, what prints out? If you print the values from the data set, what is the value for that value, Is it different than when you created the list?

You may need to use the DatasetBuilder class to specifiy specific column types for the dataset, that could be where the conversion is happening.

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 5:45pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/7 "2022-12-19T17:45:22Z")

</div>

Here is what I am seeing for the tag values into ignition. This is what is coming out in my csv file

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/cad244206466b83fdd1cbae40188cab67cb1232d.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5a5f4a3766fae553bea615e000bdfe1cdd3e863b.png)

The values are a little off because the script to create the csv ran before values changed but you get the idea

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 5:50pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/8 "2022-12-19T17:50:58Z")

</div>

Also to your point I am writing the dataset to a dataset tag in the script. This is what I am seeing for the dataset tag. It includes the full values

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/876902dec05a345eee9a6f965484ee2b1a542938.png)

It seems the dataset is then fine

---

<div class="post-metadata">

**Author:** ![rbabcock](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbabcock/32/13425_2.png) [@rbabcock](https://forum.inductiveautomation.com/u/rbabcock)\
**Post date:** [December 19, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/9 "2022-12-19T17:57:30Z")

</div>

Sometimes the value displays differently, based on what is interpreting it. For example:

```auto
Totdataset = system.dataset.toDataSet(headers, [totalizers])
from pprint import pprint
pprint(Totdataset.getValueAt(0, 0))
print(Totdataset.getValueAt(0, 0))

```

yields the value each way

```auto
1000000028920.2305
1.00000002892e+12

```

The only way I could get the CSV to have the correctly formatted value was to flag localization

```auto
system.dataset.toCSV(Totdataset, localized=True)

```

which formats it like this: "1,000,000,028,920.2305". Depending on how you're reading the CSV that may be an issue.

EDIT: This was done with readBlocking, instead of readAll. But, as always, it's best to use the most recent, supported functions.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 19, 2022, 6:16pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/10 "2022-12-19T18:16:34Z")

</div>

Consider fixing it with formatting in the target application (Excel, whatever), to avoid losing information. LREAL carries 16 significant digits. Totalizers are notorious for needing them.

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 6:37pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/11 "2022-12-19T18:37:19Z")

</div>

That did it! Set localized to True and then I did a round(data.value),1 to get it to one decimal place

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [December 19, 2022, 6:40pm UTC](https://forum.inductiveautomation.com/t/lreal-plc-data-type-in-ignition/67793/12 "2022-12-19T18:40:19Z")

</div>

This is a file that will be overwritten each day. I was under the impression you could not set certain properties to the csv file through the system.dataset.toCSV function.
