MORE HELP ON TEXT FILES - URGENT
I'm Writing a Business Professionals Of America Database for the High School I attend and I need to know about some input and output to text files
Suppose I have a String called 'line1'
I also have a textfile called 'C:/......../info.txt'
In that text file I have the line '34865-M-J-101'
Can someone show me how to take that line out of the text file and place it into 'line1'???
The second thing I need to know is.............
I have a TextField in my java program, once the user enters something into the textfield and clicks a button I made, I need to take that information and output it to a text file. I know how to take the information OUT of the textfield and into a variable, I just need the code on how to output the variable's information to a textfile.
I'm Writing a Business Professionals Of America
Database for the High School I attend and I need to
know about some input and output to text filesHow much information do you have. If there is a lot of information I would recommend using an actual database instead of a text file.
Suppose I have a String called 'line1'
I also have a textfile called 'C:/......../info.txt'
In that text file I have the line '34865-M-J-101'
Can someone show me how to take that line out of the
text file and place it into 'line1'???That looks like some kind of ID. What you could do (also I'm assuming you don't have a tremendous amount of data, otherwise use an actual database) is use the java.util.Properties class and setup your data as lines with "34865-M-J-101=some entry for that". Then you could use code like:
Properties props=new Properties();
props.load(new FileInputStream("C:/....../info.txt"));
String line=props.getProperty("34865-M-J-101");The line would then have "some entry for that".
The second thing I need to know is.............
I have a TextField in my java program, once the user
enters something into the textfield and clicks a
button I made, I need to take that information and
output it to a text file. I know how to take the
information OUT of the textfield and into a variable,
I just need the code on how to output the variable's
information to a textfile.Assuming you took the approach above something like:
props.store(new FileOutputStream("C:/....../info.txt", null));The best way to do this really depends on how much information there is and what you need to do with it. For example, if you do not have some unique key for each entry, you probably don't want to use properties.
Similar Messages
-
Hash Table copy to Text file : urgent
HI
I have a hash Table which cintaine id's and name pair Now i want to copy or dump this whole table into a Text file, But i do not know how to do this .
This is very urgent for me.
Please help me .
PreetiHashTable is Serializable
use ObjectOutputStream to write to the file and use ObjectInputStream to read from the file
HashTable ht=new HashTable()
ht.put("key1","value1");
ht.put("key2","value2");
FileOutputStream ostream = new FileOutputStream
("Hash.txt");
ObjectOutputStream oos = new ObjectOutputStream(ostream);
oos.writeObject(ht);
oos.flush();
oos.close();//dont forget thisuse ObjectInputStream To read HashTable from file
use readObject() method -
Interactive Bar/pie chart and line graph, data from excel/text file -urgent
Hi,
I have a huge data in excell sheet which keeps updating every month. Data basically consists of service provider and there respective subscribers from various regions of the country over the years. The requirement is to give the viewers an interactive page where in they can make various combinations and can compare, cross examine data according to thier choice.
We want the pie chart / bar graph or line graph to be created on the fly according to the combination made by the user.
The site is hosted on a red hat linux server. how can a connection to the excel spreadsheet be made or is it possible to read from the text file if the entire data is exported to a text file.
Is there any ready made tool/code available which can be customised according to the need.
Thanx in advance
Regards
PrakashI certainly wouldn't pay for the graphing package at the previous link. check out http://www.object-refinery.com/jfreechart/ for a free, open-source, much better looking graphing package.
-
Newbie requesting help reading text file.
I'm a student; this is not homework; this is study. Next week I will be called upon to explain to a class how to read and write basic text files with java and Scanner methods. I can not explain what I don't understand. I have a lab partner who understands the process, I'm still not clear! We just came from separate java1 classes, and because he understands I/O stuff, I am using the code his teacher taught to try and understand this, so I'm hoping I can keep the code identical in the try block and fileReader and scanner lines:
import java.io.*;
import java.util.Scanner;
public class FileInput
public void copyCharacters()
//---I'd like to *NOT change these two lines below and the code inside the try block if possible
FileReader fr = new FileReader("widgets.txt");
Scanner in = new Scanner(fr);
try
while( in.hasNext() )
String text = in.next();
System.out.println(text);
in.close();
//out.close();
catch(IOException e){
System.out.println("error opening file" + e);
public static void main (String[]args)
FileInput reader = new FileInput();
reader.copyCharacters();
}As I said, I just wnat to get a feel for simply opening closing, reading and eventually writing to a output file, but I am getting an error: ----> 'class' or 'interface' expected <----
Edited by: RogerDodgr on Jan 10, 2009 10:56 AM
typo
Edited by: RogerDodgr on Jan 10, 2009 11:07 AM TyposI can not explain what I don't understand. I have a lab partner who understands the process, I'm still not clear!Ask your partner to explain and/or read some tutorial or other - including [Sun's|http://java.sun.com/docs/books/tutorial/essential/io/index.html] on this site.
I'm not trying to put you off, but "explaining how to read and write basic text files" is one of those questions that involve a mix of techniques (what classes, what methods to call and when) as well as principals (the intuitive "what's going on" behind the code - the "why" to accompany the "what"). Carefully edited tutorials with lots of examples, and face to face dialogue that can pick up immediately on your answers/questions/speculations and lack of understsanding - these will win out over a forum like this any day.
The tutorial linked to above is a bit long (given the rather simple sounding question). But if there are specific points it makes which you can't understand, ask away. (or ignore this whole post! there may be others up to the task of answering.)
I am getting an error: ----> 'class' or 'interface' expected <----This is often the compiler's way of saying "your braces don't line up!". Work upwards from where the error occur and find the } which should be a {. Any way, that's the error here. -
Update/delete text file - Urgent
hi guys, i have a text file. Using io package i would like to search a particular string in the file. when i got the search string either i have to update some text in that row or i have to delete the row. how can i do that. If any one tried pls let me know with code. Ur valuable suggestion are welcome.
thax in advanceAn obvious method is to copy the whole file with the changes made into a temporary file .
After the operation delete the orginal file and rename the temporary file to orginal file. -
Bulk Data - Insert / Update from text file - Urgent
hi,
Consider there is a Table A. There are around 1.7 Million
Records.
i have a situation that i will be getting the Data,
Every two Weeks, around 100 - 200 thousand Records.
I have to do some calculations.
If any Old Data Exists, then update the Data
for the Non - Primary Key Fields.
Else
I have to Insert the New Data.
Most of the time, i will be getting update information.
very few hundreds, insert records.
Please, help me, by providing the techniques or tools.
Is it posssible to automate the whole process.
Sreedhar V
nullSreedhar V (guest) wrote:
: hi,
: Consider there is a Table A. There are around 1.7 Million
: Records.
: i have a situation that i will be getting the Data,
: Every two Weeks, around 100 - 200 thousand Records.
: I have to do some calculations.
: If any Old Data Exists, then update the Data
: for the Non - Primary Key Fields.
: Else
: I have to Insert the New Data.
: Most of the time, i will be getting update information.
: very few hundreds, insert records.
: Please, help me, by providing the techniques or tools.
: Is it posssible to automate the whole process.
: Sreedhar V
Here's a process that might help:
create a temporary table the same format as the flat file.
create a sqlldr control file to load the data from the file into
the temp table
create a pl\sql or JAVA script to cursor through the records
from the temp table and for each row see if there is a match on
TABLE A. If so this is an update, if not it is an insert.
If you are in a Unix environment you can write a shell script to
automate the whole process and schedule it in kron.
null -
Is xml is more Memory and CPU stealer then text files
Is XML steal CPU and Memory usege more then reguler text files ?
if yes then how mutch?
Thanks itzik.XML is not a better way to parse data than text or fixed length. It is a STANDARD way for everyone to parse/send data.
With a fixed length/text file, you had to know the exact position of every field. With XML, the fields describe themselves. Obviously, since the fields are no longer implied, the tags that label each element will increase the size of the file.
The tradeoff is that DOM/SAX parsers offer an industry wide standard for parsing this type of data. With a DTD (or Schema), you can also include the required format of the doc to enforce the structure where with a text file you usually had to distribute a document with mappings. -
Double quotes missing in CSV file but exist in text file from AL11
Hi I am sending a file to AL11 with one of the fields having double quotes Like "field value" . When i download into Text file i am seeing the quotes but not when download as CSV file from Al11. Any SAP notes for this . If i add multiple quotes ' """" ' to have in csv I am seeing more quotes in text file which is not accepted . Please reply if anyone worked on this before . Thanks Kamesh
The CSV file also has the quotes (check in notepad), but when opened in MS Excel, Excel has a feature to ignore double quotes and consider the comma inside the quotes as part of field, not as a field separator.
-
Regarding utility for converting plb to text file
sir,
i would like to know if there is any utility to
convert .plb file(binary file) to text file.
urgent reply anticipated
Thanks in advance
MurthyI just wrote one like that a couple of days ago.<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="personInfo">
<xsl:value-of select="name"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="address"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet> -
Urgent Help:read from text file and write to table
Hi,
I'm a super beginner looking for a vi to read this data from a text file and insert it into a table:
#19
Date: 05-01-2015
ID= 12345678
Sample_Rate= 01:00:00
Total_Records= 2
Unit: F
1 03-23-2015 10:45:46 70.1 3.6
2 03-23-2015 11:45:46 67.7 2.7
Output table
# date time x y Sample rate Total Records
1 03-23-2015 10:45:46 76.8 2.8 01:00:00 2
2 03-23-2015 10:45:46 48.7 2.1 01:00:00 2
Thanks for your help in advance.
Attachments:
sample.txt 1 KBjcarmody wrote:
Will there always be the same number of rows of noise header information?
Show us how you've read the data and what you've tried to do to parse it. Once you've got the last rows, you can loop over them using Spreadsheet String to Array (after cleaning up a few messy spaces).
Jim,
I didn't know you're that active on here.
Yes, There will always be the same number of noise header information.
I'll show you in person
Regards, -
Urgent Help to convert text file to XML
I have a text file containing data. The file has following format:
Name : ABC Consultants
Address : B50, 5th Street,
Sector 70,
Salt Lake
Calcutta-700048
Contact Person : Mr. Sanjay Ghosh
Designation : Senior Consultant
Phone No. : 033-373575
Fax : 033-374590 Extn. 06
E-mail : [email protected]
Website : www.abc.com
Nature of Business : HR consultancy
Cities of Operation : All over India & Abroad
Other Information : Company specialises in providing top executives to MNCs and corporate giants like IBM, Oracle and Microsoft.
There is information regarding other companies in the similar way.
The objective is to create a XML file out of this text file by proper tagging like
<name> company name comes here </name>
<address> company address comes here </address>
..so on
My approach:
I am trying to read from the text file and store the contents into a vector object. Then I would use the vector object to create different nodes of the XML file through JDOM.
My vector object is getting created but when I am writing it back , it is giving garbage value.
Is my approach correct ..Please Suggest..
Thanks in advance..
NilotpalFollowing is the code, which i have written. I am writing the contents to another text file - "output.txt"
<CODE>
try{
// Open an input stream
BufferedReader inputData = new BufferedReader(new FileReader("companyList.txt"));
String buffer = null;
while ((buffer = inputData.readLine()) != null)
{StringTokenizer words = new StringTokenizer(buffer, ":;");
Object[] lineData = new Object[words.countTokens()];
int counter = 0;
while(words.hasMoreTokens())
{lineData[counter] = words.nextToken();
counter++;
data.addElement(lineData);
Object[] obArrayData = new Object[data.size()];
for(int i=0; i<data.size(); i++)
{ obArrayData[i] = (Object[]) data.elementAt(i);}
//write to a text file
FileWriter fw = new FileWriter("C:\\Projects\\com\\gayatrii\\convertor\\output.txt");
for(int i = 0; i < data.size(); i ++)
fw.write(data.elementAt(i).toString()+" \n");
fw.close();
</CODE> -
Reading Text File from selection Screen and populating table (Urgent)
Hi All,
I have some requirment like i in my report i have to initial my Input feild from text file is it good to populate a internal table or range.
I have three feild in a excel file that entry can more then 500
data example
Matnr Date Day
A1 10.07.2007 12
B1 10.07.2007 10
A1 19.07.2007 15
C1 20.08.2007 30
E1 11.09.2007 12
This report for Price Protection claim.
even u can help me out with proper table plz this is urgent.Hi..
<b>parameters:</b>
p_file(50) type c.
<b>data:</b>
begin of itab occurs 0,
matnr type vbak-matnr,
date type sy-datum,
day(2) type n,
end of itab.
<b>at selection-screen on value-request for p_fname.</b>
perform get_path.
<b>start-of-selection.</b>
<b>CALL FUNCTION 'GUI_UPLOAD'</b>
<b>EXPORTING
FILENAME = p_fname
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'</b>
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
<b> TABLES
DATA_TAB = itab</b>
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
This Sub routine is used to get the file name
*There are no interface parameters passed to this subroutine.
FORM get_path .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = P_FNAME
DEF_PATH = ' '
MASK = ' '
MODE = ' '
TITLE = ' '
IMPORTING
FILENAME = P_FNAME
RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " get_path
data: -
Read from Text File - Help Bug?
Hi - I am currently working on LV8 and I think that there is some misunderstanding potential in the help file. To be more exact in the help to the "Read From Text File" VI.
The description for "count":
" ... If count is <0, the function reads the entire file. The
default is –1, which indicates to read a single line if you placed a checkmark
next to the Read Lines shortcut menu item and to read the
entire file if you removed the checkmark next to the item. "
If count is lower than zero, the function reads the entire file. That sounds clear to me.
The default is -1, which indicates to read a single line if you placed a checkmark next to the "Read Lines" shortcut menu item. Now what? Does it read a single line or the whole file?
.. and to read the entire file if you removed the checkmark next to the item. I thought it reads the whole file if I use -1 ?
the VI itself behaves as I'd expect it to:
* If I place a checkmark next to Read Lines and put -1, I get an array containing the lines
* If I remove the checkmark, I get only a single string item.
Now where is the error? Is the VI not working properly or only the description a little bit ... strange ??hein??
?what?
Both you guys lost me..
And I drink coffee without sugar (being sweet enough, already)
Here is what I get from Context Help on the Read From Text File:
Read from Text File
Reads a specified number of characters or lines from a byte stream file. By default, this function reads all characters from the text file. Wire an integer value to count to specify how many individual characters you want to read starting with the first character. Right-click the function and place a checkmark next to the Read Lines option in the shortcut menu to read individual lines from the text file. When you select the Read Lines option in the shortcut menu, wire an integer value to the count input to specify how many individual lines you want to read from the file starting with the first line. Enter a value of -1 in count to read all characters and lines from the text file.
Humm.
New feature (again).. If you select checkmark the Read Lines option, it will not send the text to a sting indicator, as shown in the attached image. If selected, then it's expecting to write lines to an array of strings... WHY??? I don't know.. I'll ask..
Strange... LV8 is full of mysteries...
RayR
Attachments:
bad write file.JPG 33 KB
more bad write file.JPG 12 KB -
Read from Text File Detailed Help need Clean-up
This is probably well known and nobody has bothered fixing it but the detailed Help of the "Read from Text File" function is sort of ambiguous:
- statement 1: refnum out is the refnum of the file that the function read. You can wire this output to another file function, depending on what you want to do with the file. The default is to close the file if it is referenced by a file path or selected from the file dialog box. If file is a refnum or if you wire refnum out to another function, LabVIEW assumes that the file is still in use until you close it.
- statement 2: If you wire a path to file, the function opens the file before reading from it and closes it afterwards.
I have found statement 1 to be correct, which makes statement 2 incomplete (and sort of tautological in the sense that 1) you expect LabVIEW to open the file before reading from it if you provide a path instead of a refnum... and 2) if you use a path input to file AND use the refnum out for some other function, the file is NOT closed, as correctly stated in statement 1).
Just sayin' ...X,
It deeply concerns me that you would take my response to mean indifference. I certainly had no intention to belittle what you had to say. On the contrary, I took this up with the concerned team, and had a small discussion. If you say that what someone says on this forum is of lesser or no value to National Instruments, you could not be more wrong. It defeats the whole purpose of this public forum.
My point was not that it is not an issue, it certainly seems to be. Please be rest assured that even if it does not look like it from the outside, each comment however big or small is taken back to our workplaces and some thoughts poured over it.
On the whole, I recognise that I had a role to play in this misunderstanding of tone, and I sincerely apologise.
Warm Regards,
Prashanth N
National Instruments -
hey ppl
i have a datagrid in my form.i need to read input(fields..sort of a database) from a text file and display its contents in the datagrid.
how can this be done.. and also after every few seconds reading event should be re executed.. and that the contents of the datagrid will keep changing as per the changes in the file...
please help as this is urgent and important.. if possible please provide me with an example code as i am completely new to flex...
thanks.....It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing.
Maybe you are looking for
-
my ipad has disabled itself after asking for a passcode after updating ios7 now tried to restore it but didnt work
-
I have just two items on my Time Capsule. A vault of photos from Aperture and a backup of my hard disk. The hd backup is scheduled to update automatically every few hours and, according to the motion of the icon on my desktop, it does so. My photo va
-
Why do I have 2 iclouds in address book?
Recently my Mac's Address Book duplicated my iCloud. Now I have 2 iClouds plus my "On My Mac" contacts. So, if I click on "All Contacts", I will see duplicates. I only want one iCloud and an On My Mac copy. So, how do I delete one of the iCloud a
-
The form field arguments.image did not contain a file.
Hi there, I'm getting a strange error with a simple file upload and I can't figure it out for the life of me. It's odd, because old code I have written before has worked fine in this area, and I really honestly can't see where I am going wrong. First
-
Adding additional tables to the extractor configuration
Hi Experts, Can you please help me adding additional tables to the SAP extractor and to configure the field data in the orgstructure to show a flag against the position. Luke - I have tried using the option said by you from Application-wide Settings-