# Scripting the message to different line and show in ignition

**URL:** <https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295>\
**Category:** General Discussion\
**Tags:** scripting\
**Created:** [April 29, 2020, 8:20am UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295 "2020-04-29T08:20:37Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [April 29, 2020, 8:20am UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/1 "2020-04-29T08:20:37Z")

</div>

i have one message in Chinese with \n to divide them to different lines:

Message is  
‘计划编号: 5000288049 箑号: 19G106965\n 物资编码: R581250011 物品: 74NT9500NT扶手带\n 硛度: 33.1米 数量: 2条 ATO:TXZ153100\n 箱头制造\n PO:4531430139\n REV#: -\n 出口包装\n Ching Long Shopping Centre\n H K\n’  
i want to show this message in the ignition in different lines

so i do a test in scripting

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8e04b933e15e7ead4c4583377a049829f5a66fbc.png)  
if i first store the data in the tag(string or text), and read the value from that tag, then i trigger print  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/41ba142d07d5108de2089d56cd1fe1fa02410912.png)  
i found \n still inside, all the data in 1 line

if i just give the data to Message directly  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e6e79c71b588fc2453320ff51c25067b26be3229.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/dff77a11da502da9ff310f587af2dbf38e0a4660.png)  
the data are in different line and the \n disappear

1. I don’t know the difference between these two scripting?

2. if i have the data in different line, how can i disappear them in the ignition interface?

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [April 29, 2020, 12:14pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/2 "2020-04-29T12:14:47Z")

</div>

If you want the message to be shown in a label or something, try use **HTML**.  
So, you have to put **\< HTML \>** before your message and replace the **/n** with **\< br \>**.

PS: Inside the Scripting Console you’ll see the message as a single line, but if you put your message in a label it will be formatted correctly.

---

<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:** [April 29, 2020, 12:20pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/3 "2020-04-29T12:20:33Z")

</div>

It has nothing to do with Chinese. In python string constants, the backslash is an escape character that causes the next character to be interpreted as a control code. So when you supply the string as a constant in the script console, python is changing those `\n` entries to an actual ASCII LineFeed code. If you want string tag to behave the same, you must supply line feed codes in the string tag.

A TextArea component can do this (and display the separate lines properly).

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [April 29, 2020, 2:27pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/4 "2020-04-29T14:27:47Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/094e1ff14c08c11a40cc2b16ab85e079edf38af7.png)  
I have try to follow your advise, binding it to a label , it works  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d7146ecb567fc58276cc1a0556132a6ac3b24952.png)

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [April 29, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/5 "2020-04-29T14:46:17Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2021261b3df43a03c26be954159a2bae83da0474.png)  
i have 1 Chinese word CSV document

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7912d4f6d0a234694b3afe90bed639ed67251b0f.png)  
i following the ignition 8 manual to import the csv to a power table  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fdce8bc63916039958db828a125863677cb36229.png)  
i found the power table can’t show Chinese, do i have some solution to let power table to show the Chinese?  
Many thanks in advance

---

<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:** [April 29, 2020, 3:36pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/6 "2020-04-29T15:36:03Z")

</div>

I would expect the problem to be jython’s csv module, not the power table. jython is built on python 2.5 (2.7 for Ignition v8), which doesn’t do multibyte character sets properly.

If you can restructure your CSV file slightly to follow Ignition’s dataset import/export format, I would expect that to handle the characters correctly. Use [system.file.readFileAsString()](https://docs.inductiveautomation.com/display/DOC79/system.file.readFileAsString) with utf-8, then use [system.dataset.fromCSV()](https://docs.inductiveautomation.com/display/DOC79/system.dataset.fromCSV) to yield the dataset.

If you cannot modify the CSV format, or do not want a dataset result, you can directly use Ignition’s underlying [CSV parser/writer package](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/com/inductiveautomation/ignition/common/util/csv/package-summary.html).

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [April 30, 2020, 3:48pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/7 "2020-04-30T15:48:08Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/309a5a7795c558ca5b9cdb77c69e4249148fd416.png)  
I following the manual  
path = system.file.openFile(“CSV”)  
if path != None:  
contents = system.file.readFileAsString(path)  
event.source.parent.getComponent(‘Text Area’).text= contents  
these four line , i can see the text Area is showing Chinese

After step 1 success, i follow step 2  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2916d1235bba05745360d9359c0ce5fbb6d9100c.png)  
data = system.dataset.fromCSV(event.source.parent.getComponent(‘Text Area’).text)  
event.source.parent.getComponent(‘Power Table’).data=data

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

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/79e80fe382d6b8dd7dea4dd11bd8be4707dabb49.png)  
i suppose the red line high light is the Name

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 30, 2020, 4:04pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/8 "2020-04-30T16:04:37Z")

</div>

> [@pturmel](#):
>
> If you can restructure your CSV file slightly to follow Ignition’s dataset import/export format, I would expect that to handle the characters correctly. Use [system.file.readFileAsString()](https://docs.inductiveautomation.com/display/DOC79/system.file.readFileAsString) with utf-8, then use [system.dataset.fromCSV()](https://docs.inductiveautomation.com/display/DOC79/system.dataset.fromCSV) to yield the dataset.

@yifeiliu08 You didn't do that. There is extra data at the top that needs to exist in order to use [system.dataet.fromCSV()](https://docs.inductiveautomation.com/display/DOC80/system.dataset.fromCSV).

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [May 1, 2020, 1:53pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/9 "2020-05-01T13:53:38Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9a3adf991f37829428736f25eca48329f6dd0b5e.png)  
I Follow the manual instruction, create a csv document, you can see the upside picture  
when i use notepad open, it will have the same structure as manual  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4c27f9479157a328ac9d73eaf2f936cacd3c74d2.png)

then i scripting

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4e0653e6d31dd33a2eee04d0e643a49cf69ef89c.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/14ed254ab635094c231b03b8cb0c8b8560f3a543.png)  
it still fault, expected names on line 1, i am confused , it seems my csv document totally the same as the manual , why still report fault ?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 1, 2020, 2:14pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/10 "2020-05-01T14:14:23Z")

</div>

post your csv file here. I suspect there are extra characters in there.

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [May 1, 2020, 2:17pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/11 "2020-05-01T14:17:57Z")

</div>

yes, you are right, when i copy and paste again , it works, thanks a lot

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [May 1, 2020, 2:54pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/12 "2020-05-01T14:54:37Z")

</div>

i have check the first action use the special csv format , it works

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f89db3ab0fc6b6bc10d5bca9ccbc05a26b76fe92.png)  
but as a new user, i think this page is much easy to understanding and test  
[https://docs.inductiveautomation.com/display/DOC80/Exporting+and+Importing+a+CSV](https://docs.inductiveautomation.com/display/DOC80/Exporting+and+Importing+a+CSV)  
also i have try to use CSV.reader as the manual shows, Chinese can’t be show in powertable and in the console  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2bc1426050a30ea538f1e71a7c6de2d843d27734.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/88b6bcbab39838d364bd398da4a63aa445979c68.png)  
thanks for your suggestion.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 1, 2020, 3:20pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/13 "2020-05-01T15:20:05Z")

</div>

If you post or pm me a sample of your csv file, I can take a closer look. There is likely an encoding issue going on.

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [May 2, 2020, 2:23pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/14 "2020-05-02T14:23:53Z")

</div>

[test2.csv](https://forum.inductiveautomation.com/uploads/short-url/oqUP2dJt9qO2CBhf3FJV6Nv4sqr.csv) (256 Bytes)  
Here is the document, i can’t find any difference  
But if i following the manual use the notepad copy and paste create a new csv document it will have no issue  
i have also try to first create a excel , then convert it to a csv

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8adb45a302248bd69f0a6516f987634c4b760a18.png)  
after i covert the excel to csv, i will found this will be a double’,’ after the names, and i have to delete the ‘,’ and save as again.  
So currently i will use the example.csv as a demo, i will base on this document do some modification

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 4, 2020, 2:12pm UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/15 "2020-05-04T14:12:52Z")

</div>

Creating a csv file in Excel here does not give an import issue, even with the extra commas after #NAMES.

Post a file that will not work, and let’s check for extra bytes before #NAMES. A BOM (byte order marker) comes to mind.

---

<div class="post-metadata">

**Author:** ![yifeiliu08](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@yifeiliu08](https://forum.inductiveautomation.com/u/yifeiliu08)\
**Post date:** [July 10, 2020, 8:30am UTC](https://forum.inductiveautomation.com/t/scripting-the-message-to-different-line-and-show-in-ignition/34295/16 "2020-07-10T08:30:30Z")

</div>

I meet another problem with the csv import issue

[ansi.csv](https://forum.inductiveautomation.com/uploads/short-url/o1a6urG5TsY6iIrUwF0orrD7Vbi.csv) (264 Bytes) [UTF8.csv](https://forum.inductiveautomation.com/uploads/short-url/gCCcQivTmz4XknECF2Pf8B02aPF.csv) (292 Bytes)  
i have create a csv document with ansi encoding method

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/e/eebe97790fd4d07df8b38c1b760d47acd18c2b50.png)  
i will success import them with no fault  
but my content have chinese , some computer will have issue with the ansi encoding  
so i try to save as utf-8  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd49b8f27ef759b1c8a35310e292366d08ad9cc6.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/782e49c7c07335b0bab0ff7e93d09b2f0170f06e.png)  
then i use notepad to open them and i can't see any difference between these two encoding method  
but if i import the UTF8 CSV , it will report fault  
![image|690x435]  
(upload://ndvxv3OKcxhUfKLx2F1kdMqojOi.png)  
can you help me download the utf8 to verify what's wrong?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b2c419eab11716b1e1de934f5344474ebde2508e.png)  
here is my scripting

path = system.file.openFile("csv")  
data\_string = system.file.readFileAsString(path)

# Convert the string to a dataset and store in a variable

data = system.dataset.fromCSV(data\_string)

# Assign the dataset to a table

#event.source.parent.getComponent('Power Table 3').data = data  
query=""" INSERT INTO [dbo].[SalesText1]  
([SaleOrder]  
,[Date]  
,[Pos]  
,[Remark]  
,[UpdateTime])  
VALUES  
(?,?,?,?,SYSDATETIME())  
"""  
py\_TableData = system.dataset.toPyDataSet(data)  
system.gui.messageBox(u'请注意，数据在上传中， 请稍后')  
for row in py\_TableData:  
args = [row[0], row[1],row[2],row[4]]  
system.db.runPrepUpdate(query, args)  
system.gui.messageBox(u'数据传送完毕')

many thanks in advance
