how to input data from txt file? |
![]() ![]() |
how to input data from txt file? |
23rd July 2010 - 09:41
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 20-July 10 Member No.: 634 |
Hello:
There is a question. When I input data from the file and retrain the system, for instance, importing data from the 'police.txt' of Police tutorial, I only know to realize it by the following mundane code. I believe Peltarion should be a simple way to read data directly form the file of 'police.txt' , but I haven't found it. Could you tell me how to do it? Thanks! Best, Kevin string strFile = My.Application.Info.DirectoryPath + "\\police.txt"; object[,] temPloice = new object[1699, 10]; Matrix Mp = new Matrix(1699, 10); FileSystem.FileOpen(1, strFile, OpenMode.Input); temP = FileSystem.LineInput(1); for (this.I = 0; this.I <= 1699; this.I++) { for (this.J = 0; this.J <= 8; this.J++) { FileSystem.Input(1, ref temPloice(I, J)); if (J != 8) Mp(I, J) = temPloice(I, J); if (J == 8) { if (Strings.Trim(temPloice(I, J)) == "Pass") { Mp(I, J) = 1; Mp(I, J + 1) = 0; } else { Mp(I, J) = 0; Mp(I, J + 1) = 1; } } } } FileSystem.FileClose(1); SYS.Input_CSV = Mp; |
|
|
|
26th July 2010 - 03:38
Post
#2
|
|
|
Peltarion ![]() ![]() ![]() ![]() Group: Peltarion Team Posts: 117 Joined: 10-September 08 Member No.: 4 |
Add a reference to Peltarion\Synapse\Plugins\CSVFormat.dll and then you can use the same parser as Synapse does (i.e. the format that reads CSV files):
CODE Peltarion.Plugins.Data.CVSFile c = new CVSFile();
string rrow = "[^\r|^\n]+"; string rcol = "[^ ^,^ ^\r^\n*]+"; string path = @"C:\Program Files (x86)\Peltarion\Synapse\Sample Data\Police\police.txt"; NamedSignal s = c.ParseToSignal(c.ReadTextFile(path), new System.Text.RegularExpressions.Regex(rrow), new System.Text.RegularExpressions.Regex(rcol), -1, 0); SYS.Input_CSV = s.Data; |
|
|
|
26th July 2010 - 08:37
Post
#3
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 20-July 10 Member No.: 634 |
Hello Luka,
Thanks for your respones. However, I can't find and add the reference of 'CSVFormat.dll' in my Peltarion. there are only 'CSVFile.dll','CSVOut.dll','CSVOutGui.dll' files at the directory of 'Peltarion\Synapse\Plugins\ '. I try to quote the 'CSVFile.dll' file to solve the problem, but I am failure. My version is 1.3.6, what's wrong with it? best, Kevin |
|
|
|
26th July 2010 - 22:33
Post
#4
|
|
![]() Newbie ![]() Group: Members Posts: 1 Joined: 23-July 10 From: Austin Member No.: 639 |
Hello: There is a question. When I input data from the file and retrain the system, for instance, importing data from the 'police.txt' of Police tutorial, I only know to realize it by the following mundane code. I believe Peltarion should be a simple way to read data directly form the file of 'police.txt' , but I haven't found it. Could you tell me how to do it? Thanks! Best, Kevin string strFile = My.Application.Info.DirectoryPath + "\\police.txt"; object[,] temPloice = new object[1699, 10]; Matrix Mp = new Matrix(1699, 10); FileSystem.FileOpen(1, strFile, OpenMode.Input); temP = FileSystem.LineInput(1); for (this.I = 0; this.I <= 1699; this.I++) { for (this.J = 0; this.J <= 8; this.J++) { FileSystem.Input(1, ref temPloice(I, J)); if (J != 8) Mp(I, J) = temPloice(I, J); if (J == 8) { if (Strings.Trim(temPloice(I, J)) == "Pass") { Mp(I, J) = 1; Mp(I, J + 1) = 0; } else { Mp(I, J) = 0; Mp(I, J + 1) = 1; } } } } FileSystem.FileClose(1); SYS.Input_CSV = Mp; ______ Thanks for sharing. I have learned a lot. I will try that if it works. -------------------- |
|
|
|
27th July 2010 - 00:43
Post
#5
|
|
|
Peltarion ![]() ![]() ![]() ![]() Group: Peltarion Team Posts: 117 Joined: 10-September 08 Member No.: 4 |
Hello Luka, Thanks for your respones. However, I can't find and add the reference of 'CSVFormat.dll' in my Peltarion. there are only 'CSVFile.dll','CSVOut.dll','CSVOutGui.dll' files at the directory of 'Peltarion\Synapse\Plugins\ '. I try to quote the 'CSVFile.dll' file to solve the problem, but I am failure. My version is 1.3.6, what's wrong with it? best, Kevin Sorry, my bad - It's CSVFile.dll. Luka |
|
|
|
28th July 2010 - 13:19
Post
#6
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 20-July 10 Member No.: 634 |
Hello Luka,
I have quoted CVSFile.dll file and added 'using Peltarion.Plugins', 'using Peltarion.core',etc, but I can't define new CVSFile. The following image shows there is no option of CVSFile at all. So, it point out the following error at the line of 'Peltarion.Plugins.Data.CVSFile = new CVSFile' in the Visual studio 2008. I have tried many ways to find the solution, but I failed. Maybe, 'iLibrary.dll' should be quoted, but it is only 'oLibrary.dll' in Peltarion. Could you give me a suggestion? Thanks you in advance. Best, Kevin The image and error are as following: http://www.myspace.com/544255400/photos/48...%22%3A488669%7D The type 'Peltarion.Core.Atom' is defined in an assembly that is not referenced. You must add a reference to assembly 'iLibrary, Version=1.3.5.0, Culture=neutral, PublicKeyToken=null'. |
|
|
|
30th July 2010 - 15:42
Post
#7
|
|
|
Peltarion ![]() ![]() ![]() ![]() Group: Peltarion Team Posts: 117 Joined: 10-September 08 Member No.: 4 |
Kevin, you have to include the deployed system dll or add iLibrary.dll (found in Peltarion\Synapse\iLibrary.dll)
Luka |
|
|
|
4th August 2010 - 07:34
Post
#8
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 20-July 10 Member No.: 634 |
Hello Luka,
Thanks for your suggestion, and I have solved the problem. I used the function of multiple deployed components in order to avoid the error of namespace indefinite. Then, I added the files including CSVfile.dll,GoodCopBadCop.dll, iLibrary.dll, MoleculeParser.dll, StaticXProp.dll, XProp.dll, etc. The problem has been solved successfully at last. Kevin |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 2010-09-06 17:54 |