Read data from CSV to winccflex

nehe bhimaji

Member
Join Date
Apr 2007
Location
Dadra And Nagar Haveli
Posts
183
Dear All
How can I read data values from csv file to wincc flex internal tags then i may want to modify some value of that internal tags and then dump it to PLC
How can i achive it?
If,to read csv data in internal tag by VB then send me VB codes

Warm Regards
Nehe
 
Still some problem!!!!!

Dear Sir

Thanks for your great help i got a script on the link that you have provoided and it is working fine but there is little quiry
as below

'////////////////////////////////////////////////////////////////
' en: Script for the readout of a text file
' de: Script zum Auslesen einer Textdatei
' Created: 14-05-2007
' Version: v0.1
' Author: ZW
'////////////////////////////////////////////////////////////////
'Declaration of local tags - Deklaration von lokalen Variablen
Dim fso, f, ts, Path, field, MyZf, i, j, HiField(2,2)
'Definition of local tags - Definition von lokalen Variablen
i=0
j=0
'Definition of file extension - Definition der Datei-Extension
If bExtension = 0 Then
Path = "c:\textfile.txt"
Else
Path = "c:\textfile.csv"
End If
'Error Routine - Fehlerroutine
On Error Resume Next
'Create object - Objekt erstellen
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set f = fso_OpenTextFile(Path, 1, 0, -2)---What it mean?Please explain
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
'Loop
Do While f.AtEndOfStream <> True

MyZf = f.ReadLine
field = Split(MyZf, ";")

For i=0 To 3
field(i) = Replace(field(i), " ", "")
HiField(j, i) = field(i)
Next

j = j + 1
Loop
SmartTags("szString_1") = HiField(0,1)
SmartTags("nValue_1") = HiField(1,1)
SmartTags("nValue_2") = HiField(2,1)
'Close file
f.Close
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Readout of the data was successful!"
'// EOS /////////////////////////////////////////////////////////
 
Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.


object.OpenTextFile(filename[, iomode[, create[, format]]])

object Required. Object is always the name of a FileSystemObject.

filename Required. String expression that identifies the file to open.

iomode Optional. Can be one of three constants: ForReading, ForWriting, or ForAppending.

create Optional. Boolean value that indicates whether a new file can be created if the specified filename doesn't exist. The value is True if a new file is created, False if it isn't created. If omitted, a new file isn't created.

format Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII.
 
VB script works but some problm

Dear sir
In wincc flexible following scripts works to read data from text file but it reads only three fields of each line.My requirment is to read 7 fields of each line.I have tried it by replacing FOR LOOP at diffrent value say 4,5,6 etc but no success
Please help
////////////////////////////////////////////////////////////////
' en: Script for the readout of a text file
' de: Script zum Auslesen einer Textdatei
' Created: 14-05-2007
' Version: v0.1
' Author: ZW
'////////////////////////////////////////////////////////////////
'Declaration of local tags - Deklaration von lokalen Variablen
Dim fso, f, ts, Path, field, MyZf, i, j, HiField(2,2)
'Definition of local tags - Definition von lokalen Variablen
i=0
j=0
'Definition of file extension - Definition der Datei-Extension
Path = "c:\textfile.txt"


'Error Routine - Fehlerroutine
On Error Resume Next
'Create object - Objekt erstellen
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set f = fso_OpenTextFile(Path, 1, 0, -2)
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
'Loop
Do While f.AtEndOfStream <> True

MyZf = f.ReadLine
field = Split(MyZf, ",")

For i=0 To 5
field(i) = Replace(field(i), ", ")
HiField(j, i) = field(i)
Next

j = j + 1
Loop
SmartTags("nValue_1") = HiField(0,0)
SmartTags("nValue_2") = HiField(0,1)
SmartTags("nValue_5") = HiField(0,2)
SmartTags("nValue_6") = HiField(0,3)
SmartTags("nValue_7") = HiField(0,4)
'Close file
f.Close
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Readout of the data was successful!"
'// EOS /////////////////////////////////////////////////////////
 

Similar Topics

Hi Iam using monitouch hmi(V9 soft) with omron plc cj2m (CX programmer). In this I want to read a data from hmi to plc. The data was like...
Replies
0
Views
95
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
129
Dear Experts, Please, kindly guide me through how to read data from ABB PLC to S7-1200 Siemens PLC. I want to use Siemens S7-1200 PLC to read data...
Replies
1
Views
448
Hello, I want to send the data from Rslogix500 to Excel. I created a connection between RSlinx and Excel. The values in Excel automatically...
Replies
5
Views
1,181
Dear colleagues, I am reaching out for assistance with an issue I am having. I have a code that can successfully insert data from FactoryTalk...
Replies
6
Views
1,053
Back
Top Bottom