Retrieve data from txt file to generate CWGraph plot
Please help...I'm not sure this is even possible, but here is what I need to do. I wrote a DAQ program that utilizes the CWGraph control. Each second a data point is collected by the program and displayed in one of the CWGraphs. The only problem I have is that if the program is closed or crashes for some reason, I lose the data plot in my CWGraphs. The data points are collected in a txt file which is then later worked up in Excel. My question is, is there a way to retrieve these data points from the txt file and re-generate the plots when the program is opened back up? The program would then take back over and plot along in realtime. I hope this is clear enough to understand. Feel free to ask any questions and any input would be greatly appreciated!
Hi Chris,
There is not a shipping example that would demonstrate exactly what you are looking for in your application.
The reading and writing to a file will require general VB 6.0 programming as Measurement Studio does not provide a feature to assist you with that. If you are not familiar with File I/O in VB 6.0, this site may be a good starting point: File I/O - VisualBasic Examples .
Once again, parsing the input from the text file will also require general VB 6.0 programming. I am not sure how your text file will be delimited, but you can use this example as a guide to parsing the input from the file: Parse String Using A Specific Delimiter .
To convert from strings to numbers in VB 6.0, you can use the Val() function. More information about how to use that function can be found on MSDN: Val Function .
Once you have an array of doubles, you can plot the data on your waveform graph as usual. If you are not familiar with how to plot an array to a CWGraph, please take a look at our shipping examples. The Simple Graph example is a great starting point.
Jessica
National Instruments
Product Support Engineer
Similar Messages
-
How to read data from txt file respectively
Hi,
I am triying to form an equation between two known points. I want to do this with the attached VI, the most critical point is that I will read the x1, y1, x2 and y2 coordinates from the same .txt file. They will be written in a .txt file and I will send them to the appropriate channel (x1, y1, x2 and y2) respectively. How can I get data in a rule from a .txt file?
Could anyone please help me with this issue,
Best regards.
Attachments:
read from txt file.vi 8 KBDear RavensFan,
Thank you very much for your helps, I am bit new to labview so I usually can not find the appropriate functions easily. And a new problem has rised in my application. I should write the A, B and C numbers in the respective series to the file 2.txt. I am able to write them in a straight forward case but I want to write the next triples (A B C) in the next row. Like this;
A1 B1 C1
A2 B2 C2
A3 B3 C3
So how can I put new line constant and space constant to my VI?
Waiting for your valuable helps,
Best regards,
Attachments:
read_from_txt_fileMOD.vi 18 KB -
SQL Loader - want to access data from .txt file but don't want to insert
Hello,
I have situation where I have some data in .txt file and I have to load that data into one of my table.
My problem is I have fundtion get_id(a,b,c) in database which I have to call while loading the data to find out value of x.
I have value of a, b and c in txt file which I can access it using POSITION(N:M) in sql loader, but After accessing that value I just want to past to get_id() function and dont want to insert into sql loader.
any helpMy control file is as below
Following field is not in database but I need to pass the value to the function to get a ESC_USER_ID. any help
OFFICE_NUM filler POSITION(32:35) ,
STATION_DESK filler POSITION(45:48),
LOAD DATA
INFILE REFERRALs.TXT
BADFILE REFERRAL_LOAD.BAD
DISCARDFILE REFERRAL_LOAD.DIS
INSERT
INTO TABLE REFERRAL
EVALUATE CHECK_CONSTRAINTS REENABLE DISABLED_CONSTRAINTS
TRAILING NULLCOLS
ID sequence (1,1),
JOB_ID POSITION (16:22) "GET_JOB_ID(:JOB_ID)" ,
CUS_ID POSITION (23:31) "GET_CUS_ID(:CUS_ID)" ,
STATUS_LU CONSTANT 'F' ,
REQUEST_USER_TYPE_LU CONSTANT 'S' ,
OFFICE_NUM filler POSITION(32:35) ,
STATION_DESK filler POSITION(45:48),
REQUEST_USER_ID POSITION(143:149) "GET_ESCUSER_ID(OFFICE_NUM,STATION_DESK,:REQUEST_USER_ID)" ,
REQUEST_DT POSITION (37:44) "to_date(:REQUEST_DT,'YYYY/MM/DD')" ,
REVIEW_USER_ID FILLER ,
REVIEW_DT FILLER ,
REFUSE_REASON_LU FILLER ,
RESULT_LU POSITION (97:97) ,
NOTIFY_STATUS_LU FILLER ,
NOTIFY_DT FILLER ,
APPOINTMENT_DT POSITION (106:113) "to_date(:APPOINTMENT_DT,'YYYY/MM/DD')" ,
RESULT_DT POSITION (98:105) "to_date(:RESULT_DT,'YYYY/MM/DD')" ,
NO_MATCH_IND CONSTANT 'N'
) -
How to retrieve data from xml file into obiee reports
Hi all,
I've got a situation here. A xml file is stored as blob in oracle database table. Now i need to retrieve data/info from that xml file into obiee reports. How am i supposed to proceed with this ?I will go for a table function:
http://gerardnico.com/wiki/database/oracle/table_function
In two words, you can create a function that behave as a table. Then you create a function to pick up your xml, you parse it and you send back the rows.
I know that Oracle has also a library for XML files but I never use it until now.
Success
Nico -
Pulling output data from .txt file
Hello, I am trying to have a program that allows a user to input shopping items into the program andhave that input go to a .txt file called shoppinglist, then after the user is finished, he/she can type no to stop entering items to the list and the program will then pull all the info entered to the .txt file and output it to the screen, creating a shooping list for the user. My problem is that I am not quite sure how to output the data from the .txt file to the screen. Here is my code.
import java.io.*; // uses the java io library for the
import java.util.*; // BufferedReader class
public class week5
public static void main(String [] args)
PrintWriter inputItems = null;
try
inputItems = new PrintWriter(new FileOutputStream("shoppinglist.txt"));
BufferedReader outputItems = null;
String line = null;
outputItems = new BufferedReader(new FileReader("shoppinglist.txt"));
line = outputItems.readLine();
outputItems.close();
catch(FileNotFoundException e)
System.out.println("File file.txt not found");
System.out.println("or could not be opened.");
catch(IOException e)
System.out.println("Error reading from file file.txt.");
System.out.println("This program will create a shopping list:");
String keepGoing = "yes";
String item = null;
Scanner keyboard = new Scanner(System.in);
for (int count = 1; count < 999 && keepGoing.equalsIgnoreCase("yes");count++)
//ask for input, write it to a file
System.out.print("Please enter item # " + count + ": ");
System.out.print("");
item = keyboard.nextLine();
inputItems.println(count + " " + item);
//ask if you want to keep going
System.out.print("Do you wish to enter more items (yes/no): ");
System.out.print("");
keepGoing = keyboard.nextLine();
System.out.println("Your shopping list contains: " + item);
System.out.print("");
inputItems.close();
} All the above does is output the last item entered by the user, not the whole shopping list. Any help is greatly appreciated.nim_ramesh wrote:
outputItems = new BufferedReader(new FileReader("shoppinglist.txt"));
/* I think u want to print the text here so */
line = outputItems.readLine(); // Replace this line with that while loop
outputItems.close();
He hasn't even read the user input at that point.
OP, you need to sit down and think about the exact order you want to do things in, and rewrite your code in a logical straightforward manner. It looks like you just threw some code in hoping it would work, instead of coding deliberately. I'm not insulting you or anything, I know you're new to Java. I'm just trying to give you some advice. Look at your code, and ask yourself why the following line of code appears before you've even written anything to your file:
line = outputItems.readLine(); -
How to initialize Object Array Data Provider (OADP)with data from txt file
Hi,
I want to show in a table some columnar data from a txt file. I ran the creator demo application on OADP successfully. http://blogs.sun.com/divas/entry/using_the_object_array_data
I created a javabean class to read a txt file.However, I am stuck at how I can fill the data into an OADP array:
I am familiar with C extensively but not much at java. can anyone help??
thanks..
dr.am.mohan raoThanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
declare
O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
begin
FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
end;
PROCEDURE get_voucher_comments (
v_bu_in IN VARCHAR2,
v_voucher_in IN VARCHAR2,
v_line_in IN NUMBER,
v_userid IN VARCHAR2,
voucher_comment OUT sysadm.ap_comment_coll
IS
i NUMBER := 1;
v_comments VARCHAR2 (254) := ' ';
comment_type sysadm.ap_comment_type;
v_line_num NUMBER := 0;
CURSOR get_all_comment
IS
SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
CURSOR get_line_comment
IS
SELECT descr254_mixed FROM ps_fas_ap_comment
WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
AND voucher_line_num = v_line_in;
BEGIN
--voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
--' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
voucher_comment := sysadm.ap_comment_coll(null);
IF v_line_in = 0
THEN
OPEN get_all_comment;
LOOP
FETCH get_all_comment
INTO v_line_num, v_comments;
if i > 1
then
voucher_comment.EXTEND;
end if;
voucher_comment (i) := ap_comment_type (v_bu_in,
v_voucher_in, v_line_num, v_userid,
TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
i := i + 1;
END LOOP;
ELSE
OPEN get_line_comment;
LOOP
FETCH get_line_comment
INTO v_comments;
voucher_comment.extend(6);
voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
i := i + 1;
END LOOP;
END IF;
END get_voucher_comments; -
SQLException while trying to retrieve data from text file DB
This was originally posted in the Java Fundamentals forum,
http://forum.java.sun.com/thread.jspa?threadID=733857&tstart=10
thought I might have a better chance of getting help here.
I'm just beginning to learn JDBC stuff. I have a text file acting as my DB. So far I've been able to add rows to the table, but when I try and retrieve something from the table I get the following exception.
java.sql.SQLException: [Microsoft][ODBC Text Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.That '(unknown)' bit seems suspicious, but I don't how I would correct it. My file is set up similar to the sun tutorial I'm going through, and it doesn't specifiy the file name anywhere but the SQL statement.
All the permissions seem to be correct from what I can tell. The file isn't opened or in use anywhere else that I can see.
I've tried googling parts of the error message, but most of the reponses are dealing with MS Access or aren't java related and so far I haven't found anything helpful.
Below is my sample code.
* Created on May 4, 2006
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBProcessor {
static Connection con;
public static void main(String[] args) {
HandiAppDBProcessor app = new HandiAppDBProcessor();
// insertNamesIntoDB("John", "Doe", "Good");
retrieveNamesFromDB();
public HandiAppDBProcessor() {
super();
public static void establishDBConnection() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url ="jdbc:odbc:TextDB";
con = DriverManager.getConnection(url,"myLogin", "myPassword");
} catch (ClassNotFoundException excptn) {
System.out.println("***** ClassNotFoundException thrown");
excptn.printStackTrace();
} catch(SQLException excptn) {
System.out.println("***** SQLException - Connection Failed");
excptn.printStackTrace();
public static void insertNamesIntoDB(String firstNameIn, String lastNameIn, String standingIn) {
try {
establishDBConnection();
String firstName = firstNameIn;
String lastName = lastNameIn;
String standing = standingIn;
Statement stmt = con.createStatement();
String query = "insert into CONTACTS values ('" + firstName +
"', '" + lastName +
"', '" + standing + "');";
stmt.execute(query);
} catch(SQLException excptn) {
System.out.println("***** SQLException - Connection Failed");
excptn.printStackTrace();
public static void retrieveNamesFromDB() {
try {
establishDBConnection();
Statement stmt = con.createStatement();
String courseQuery = "SELECT FIRST_NAME FROM CONTACTS";
ResultSet rs = stmt.executeQuery(courseQuery);
while (rs.next()) {
String courseName = rs.getString("FIRST_NAME");
System.out.println("firstName = " + firstName);
} catch(SQLException excptn) {
System.out.println("***** SQLException - Connection Failed");
excptn.printStackTrace();
}Of course you won't be able to run it unless you take the time to create a text file and set it up as a data source, which I don't expect anyone to do. I was just hoping someone more experienced than I had seen this before or could spot something in my code.
Any help in any way would be appreciated.
ThanksWhen you were setting up your ODBC data source for
the Text driver, did you click on the "Options"
button? There's a lot of options in there that I
didn't understand at first glance.Yes I clicked on the options button, but the only thing there is dealing with file extensions. I left it set to the default.
I have since tried closing my connection after I insert a record, I then try executeQuery, but still no luck. Seems strange that I can write to the file but not read from it. If any thing I'd expect the opposite problem.
I have also tried using the class "JoltReport" from the sun tutorial instead of my own with the same result.
Message was edited by:
Hentay -
Import data from txt-file with reading column names
Hello,
after changing the the export of my simulation programm I can't use the solution postet here, wich works well. (I branded the post as soluted thats why I start a ne post)
Can anybode please tell me how to adept the code to import the new type of txt file. Here the name of the columns are in the first line aof the columns, like this (with ignoring the first lines).
"TIME " "Sitzbasis_X" "Sitzbasis_Y" "Sitzbasis_Z" "Achsklammer_Z" "Antriebsachse_Z" "Gegengewicht_Z" "Lenkachse_Z"
0.000000e+000 -5.472285e+003 -1.886681e+002 1.812099e+004 4.539113e+004 -1.252936e+005 -1.499764e+004 -9.806650e+003
1.000000e-003 -1.722846e+003 -1.141275e+002 8.443419e+003 2.475389e+004 -7.533712e+004 -1.138092e+004 -9.624729e+003
2.000000e-003 -3.964053e+002 -7.694600e+001 3.186345e+003 1.399086e+004 -5.653730e+004 -9.956198e+003 -9.311346e+003
I added an example file
Thanks for Help
Gabriel
Solved!
Go to Solution.
Attachments:
TXT-File.txt 115 KBHello Gabriel
You can use the DataPlugin Wizard (Navigator>>File>>DataPlugin Wizard) to define a new file import filter for your data. It will take only one minute.
Please found the uri file I create for you. Copy the attached file to your disk, unpack it and double click the uri file.
Then you can open your file by using "open with".
Hope this help
Attachments:
TXT_File_DataPlugin.zip 4 KB -
How can I import a XML file into pdf doc and how can I retrieve its data as string, in order to populate a drop down List, without using XML Schema Data Connection.
Thank you for your time!First of all you cannot load an XML file in Designer without Reader Extensions, either using xfa.host.importData or any or the import methods in AcroForm javascript. Also, since the XML objects where not available in 6, you cannot parse an XML file in anything other than version 7 of Reader/Acrobat.
So, if you do have Reader 7 (Reader-Enabled) or Acrobat 7, you could use the Attachment object to load the XML file and in turn use the XML object to parse and extract the XML data.
For example, placing the following code on a button will prompt the user to select an XML data file and manually parse it for data.
if (app.viewerVersion >= 7)
event.target.importDataObject("XMLData");
var oData = event.target.getDataObjectContents("XMLData");
var sData = util.stringFromStream(oData);
var oXML = XMLData.parse(sData, true);
event.target.removeDataObject("XMLData");
// Populate Fields
TextField3.rawValue = oXML.MyField1.value;
TextField4.rawValue = oXML.MyField3.value;
TextField1.rawValue = oXML.MyField2.value;
else {
app.alert("Acrobat 7.0 or later is required");
My external XML file is:
<?xml version="1.0" encoding="UTF-8"?>
<MyProperties>
<MyField1>A</MyField1>
<MyField2>B</MyField2>
<MyField3>C</MyField3>
</MyProperties>
Once the data is parsed, you can access it through the same hierarchy as Designer. It actually generates an XFAObject to represent each data node within the XML Document.
The other thing to note is that you cannot load data automatically from an init or calc event. You MUST have some user interaction (i.e. on the click event of a button) -
Retieve Data from ost file of OutLook 2013
Dear sir,
How can i retrieve data from ost file of outlook 2013?
the problem is: my mailbox in exchange was changed, so the outlook refused to open.I would like to suggest you to
retrieve/back
data from exchange .ost files and export to outlook 2013 process.
Click File, then click Open
& Export
Click Import/Export to open Import
and Export Wizard
Select Export to a file, and click Next.
Select Outlook Data file (.pst) and click Next
Select the folder (.OST file) that you want to export from, then click Next
Select the path where you want to put the new PST file. Click Finish.
Once you have the create new PST file, you can open it in Outlook 2013, then you can find all your data there
refer: http://www.softwareimperial.com/ost-recovery.html -
Hi all Experts,
I am a ABAPer and trying to learn BW by my own. I wanted to import data from flat file and generate some reports on that.
Can anybody tell me the steps starting from the infocubes(guess its the first step), to achieve it. Any help will be a great help for me.
Thanks in Advance,
Smita1.to start with create infoareas, infoobjects(accoring to what u have in flat file).
2.then create a cube which will include these infoobj's and activate it.
3.create an application component and then create infosource,right click and assign ds to infosource and specify ur PC file source system(whatever system u've), 4.then u'll go to the infosource screen where u need to maintain the exact order of ur file in transfer structure tab, then maintain transfer rules, activate it.
5.create upate rules for ur cube by mentioning this infosource name.
6.create infopackages and schedule them. after data is loaded to cube, use tcode rrmx and logon to bex and find ur cube and then create queries on them. -
HOW to retrieve PURCHASE ORDER DATA from archieve file and print a report
Dear all
1) I have retrieve purchase order data from archived files.
2) print purchase order data and created pdf file.
VIJ.............
Moderator message - Please ask a specific question - post locked
Edited by: Rob Burbank on Apr 28, 2009 12:00 PMDear all
1) I have retrieve purchase order data from archived files.
2) print purchase order data and created pdf file.
VIJ.............
Moderator message - Please ask a specific question - post locked
Edited by: Rob Burbank on Apr 28, 2009 12:00 PM -
How to retrieve data from a read-only Excel file
Hi Developers,
I'm trying to retrieve data from a read-only Excel file. I used the same code that I used to retrieve data from a normal Excel file, but it can't work.
My code is as followed:
try
InputStream KpExcel = new FileInputStream("kp.xls");
HSSFWorkbook Kpwb = new HSSFWorkbook(KpExcel);
HSSFSheet Kpsheet = Kpwb.getSheetAt(0);
catch(Exception e)
e.printStackTrace();
System.out.println("Exception: "+e.getMessage());
The error I received is as followed:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:224)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:210)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:191)
at photoproductionsystem.IncomingWIPPanel.getKp(IncomingWIPPanel.java:118)
at photoproductionsystem.IncomingWIPPanel.<init>(IncomingWIPPanel.java:76)
at photoproductionsystem.TabbedDisplay.<init>(TabbedDisplay.java:47)
at photoproductionsystem.Display.create(Display.java:73)
at photoproductionsystem.Display.init(Display.java:44)
at photoproductionsystem.Display.main(Display.java:229)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
... 15 more
Can someone please help me with my problem? Thanks a lot in advance!Madeline wrote:
how do I ask at Apache mailing list?I wonder why it seems to be a strange idea to some people to look at the software vendor's site for product support. :p
http://poi.apache.org/mailinglists.html -
How to read updated data from a real-time generated file?
I have a question:
I want to read the 10 mostly updated data from a real time generated data file. The data in this file is accumulated. how can i read mostly recently data to an applet? and further to using this data to draw a real-time graph? pls help
kelvin t.l. tseHi,
I think there is no "typical" way. You will have to define a convention on how the new data are stored into the file, so as to know how to accessthem. If new data are simply put at theend of your file, you may use a RandomAccessFile to read only those lines that interest you (the 1 final lines).Otherwise, you should at least know how the data file is written.
You can know if thedata file has been modified with the File.lastModified() method. This retrurns a long value corresponding to the date and hour the file was last modified. Store that value ito you appl. and perdiodically (use a Thread), compare that value with the value returned by lastModief(). If both value are NOt equal, then the file has been updated
it's all a question of knowing how the data are stored into the datafie generated.
Be also aware that you will probably have problem when your java appl. tries to read the file at the same time it is updated by the other application. I guess when theother application writes data into the file, you will not be able to read it. So, use try{} catch statements and first check to see if you can read the file with File. canRead(). If not, simply delay the reading process by asking a Thread.yield() or Thread.delay (1000)...
vincent -
How to retrieve data from an Excel file which is located on server
hi everybody,
I am using SAP NWDS 2004s .
I have done an application on how to export the table data into an Excel .
Now i want to get the data from an Excel file which is located in server and display that data which is in excel in a View for example a Sample view in Webdynpro .
In Sample view i took a uielement textview to display the data ....
can any one help how to procced further
Thanks in advance
MadhaviOptions to read Excel data to WebDynpro context
Reading Excel Sheet from Java without using any Framework
Reading Multiple Sheets of Excel Sheet from Java
Few Threads
How to Display the content of Excel file into Webdynpro Table
Is it possible to upload data from excel file(.xls)
Re: How to export the data as integer into excel sheet?
regards
Vinod
Maybe you are looking for
-
LVOOP "call parent method" doesn't work when used in sibling VI
It seems to me that the "call parent method" doesn't work properly according to the description given in the LabVIEW help. I have two basic OOP functions I am doing examples for. I can get one to work easily and the other one is impossible. Backgroun
-
How do I make my e-mail account (hotmail) the default setting
''duplicate - locking - https://support.mozilla.com/en-US/questions/830905'' cannot make attachment or links to my hotmail account, how do I make it the default setting
-
Read File From A Different Server
Hello Friends, We have a file (.txt) sitting in a server (not the application server) and there is a requirement to read data from this file into R/3. Manually, one needs a username and password to access this file as the server in which it resides i
-
how can i scanner a documents with my print hp 6520? i need a particular program or the function is already inserted in the printer? thanks This question was solved. View Solution.
-
I'm getting file path error when I run my VI. It seems that there are control characters in my filepath that are causing the error. However, I'm not sure how to fix this error. I've attached a screenshot of the error message and my VI. I'm using the