Reading value from a text file
hi ,
I have a text filed with values for this field lotid , how in PL/SQL can i make use of the values from this file
in query like select * from tbl1 a where a.lotid = values from text file ?
kindly advise
tks & rdgs
Following the example Elyo gave:
CREATE TABLE MyTable(line VARCHAR2(4000)) ORGANIZATION EXTERNAL (
default directory MyFolder
access parameters
(fields terminated by ',')
location ('test.txt')
1- use, eg.: fields terminated by ',' to indicate your separator character.
I'm not sure I understand the second question.
Similar Messages
-
Read data from a text file, one line at a time.
I need to read data from a text file, and display each line in a String Indicator on Front Panel. It displays each line, but I get Error 4, End Of Line, unless I enter an extra line of data in the file that I don't need. I tried Read From Text File.vi, made by Nat Instr, and it gave the same error.
The Read from Text File.vi reads data from a text file line by line until the user stops the VI manually with the Stop button on the front panel, or until an error (such as "Error 4, End of file") occurs. If an error occurs, the Simple Error Handler.vi pops up a dialog that tells you which error occurred.
The Read from Text File.vi uses a while loop, but if you knew how many lines you wanted to read, you could replace the while loop with a for loop set to read that many lines from the file.
If you need something more dynamic because the number of lines in your files vary, then you could change the code of the Read from Text File.vi to the expect "Error 4, End of file" and handle it appropriately. This would require unbundling the error cluster that comes fro
m the Read File function with the Unbundle By Name function, so that you can expose the individual error "status" and error "code" values stored in the cluster. If the value of the error "code" is 4, then you can change the error "status" from true to false, and you can rebundle the cluster with the Bundle by Name function. Setting the error "status" to false instructs the Simple Error Handler to ignore the error. Otherwise, pass the original error cluster to the Simple Error Handler.vi, so that you can see what the error is.
Of course, if you're not interested in what the errors are, you could just remove the Simple Error Handler.vi, but then you wouldn't see any error messages.
Best of Luck,
Dieter
Dieter Schweiss
Applications Engineer
National Instruments -
Need to read data from a text file
I need to read data from a text file and create my own hash table out of it. I'm not allowed to use the built in Java class, so how would I go implementing my own reading method and hash table class?
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. -
SQL Loader-How to insert -ve & date values from flat text file into coloumn
Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide.Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide. Try something like
someDate DATE 'DDMMYYYY'
someNumber1 "TO_NUMBER ('s99999999.00')"
someNumber2 "TO_NUMBER ('99999999.00s')"Good luck,
Eric Kamradt -
Reading characters from a text file into a multidimensional array?
I have an array, maze[][] that is to be filled with characters from a text file. I've got most of the program worked out (i think) but can't test it because I am reading my file incorrectly. However, I'm running into major headaches with this part of the program.
The text file looks like this: (It is meant to be a maze, 19 is the size of the maze(assumed to be square). is free space, # is block, s is start, x is finish)
This didn't paste evenly, but thats not a big deal. Just giving an idea.
19
5..................
And my constructor looks like follows, I've tried zillions of things with the input.hasNext() and hasNextLine() to no avail.
Code:
//Scanner to read file
Scanner input = null;
try{
input = new Scanner(fileName);
}catch(RuntimeException e) {
System.err.println("Couldn't find the file");
System.exit(0);
//Set the size of the maze
while(input.hasNextInt())
size = input.nextInt();
//Set Limits on coordinates
Coordinates.setLimits(size);
//Set the maze[][] array equal to this size
maze = new char[size][size];
//Fill the Array with maze values
for(int i = 0; i < maze.length; i++)
for(int x = 0; x < maze.length; x++)
if(input.hasNextLine())
String insert = input.nextLine();
maze[i][x] = insert.charAt(x);
Any advice would be loved =DCode-tags sometimes cause wonders, I replaced # with *, as the code tags interprets # as comment, which looks odd:
******...*.........To your code: Did you test it step by step, to find out about what is read? You could either use a debugger (e.g., if you have an IDE) or system outs to get a clue. First thing to check would be, if the maze size is read correctly. Further, the following loops look odd:for(int i = 0; i < maze.length; i++) {
for(int x = 0; x < maze.length; x++) {
if (input.hasNextLine()) {
String insert = input.nextLine();
maze[x] = insert.charAt(x);
}Shouldn't the nextLine test and assignment be in the outer loop? And assignment be to each maze's inner array? Like so:for(int i = 0; i < maze.length; i++) {
if (input.hasNextLine()) {
String insert = input.nextLine();
for(int x = 0; x < insert.size(); x++) {
maze[i][x] = insert.charAt(x);
}Otherwise, only one character per line is read and storing a character actually should fail. -
How do you read data from a text file into a JTextArea?
I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?
Student_Coder wrote:
1) Read the file messages.txt into a String
2) Initialize messages with the String as the textSwing text components are designed to use Unix-style linefeeds (\n) as line separators. If the text file happens to use a different style, like DOS's carriage-return+linefeed (\r\n), it needs to be converted. The read() method does that, and it saves the info about the line separator style in the Document so the write() method can re-convert it.
lethalwire wrote:
They have 2 different ways of importing documents in this link:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
Neither of those methods applies to JTextAreas. -
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. -
Reading data from a text file into PAS - Dimension member names truncated
Hi,
I created a procedure to dump variables and data into a text file to load into another model. I used a semicolon as a field seperator.
The data, measures and dimension members are dumped properly into a text file and no dimension member names are truncated .
However when I read the data into a measure, and I issue a peek command, dimension meber names are read in truncated
and remain full names in the text file. Any reason for this? What do I need to do to prevent this from happening?
THanks.
LungileHi Lungile,
The problem that you're likely having is that you haven't created a file description for the file from which you're reading. When loading data into Application Server from a text file, you would normally go through three steps:
1. Enter the ACCESS EXTERNAL subsystem
2. Specify the name of the file to be read
3. Specify the format of the file field names, types, widths, and positions.
If you go into the Application Server help, select "Application Server Help", then "Application Server at the command level", then "Variables and reading in data", and then "Reading an external file", you will have the process of the steps you need to follow outlined for you, including links to the help topic for each command you need to issue.
So what I think you need to do is use the DESCRIPTION command to specify the names of your fields, their type, and also their width, in order to ensure no truncation of data on the load.
The same DESCRIPTION statement is required if you want to use your text file as the source of a dimension.
Hope this helps,
Robert -
Reading PublicKey from a text file..
Hi,
I generated Public Key using RSA algorithm, and getEncoded() using Base64Encoder, after that I saved it as TEXT file. Here goes the code.
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(512);
KeyPair keypair = keyGen.generateKeyPair();
PublicKey publicKey = keypair.getPublic();
PrivateKey privateKey = keypair.getPrivate();
//Get bytes of the public and private keys
byte[] privateKeyBytes = privateKey.getEncoded();
byte[] publicKeyBytes = publicKey.getEncoded();
byte[] keypb = publicKey.getEncoded();
BASE64Encoder pubEncod = new BASE64Encoder();
String pub64 = pubEncod.encode(publicKey.getEncoded());
char c1[] = new char[pub64.length()];
pub64.getChars(0, pub64.length(), c1, 0);
String fileName1 = "D:\\PublicKey\\PublicKey.txt";
FileWriter f1 = new FileWriter(fileName1);
f1.write(c1);
f1.close();
After that, I tried to decoded PublicKey from this text file, using this code..
//Read public Key from txt file
//FileReader
FileReader fr = new FileReader("D:\\PublicKey\\PublicKey.txt ");
//BufferedReader - uses the FileReader
BufferedReader br = new BufferedReader(fr);
//String to contain lines from the file
String s;
//StringBuffer used store the file contents
StringBuffer sb = new StringBuffer("");
//Final output from the operation
String output;
//Loop through lines of the file, storing the file content
while((s = br.readLine()) != null)
{ sb.append(s + "<br>");
//Store the file contents in the output string
output = sb.toString();
//Close the file
fr.close();
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedPublicKey = decoder.decodeBuffer(output);
// bytes can be converted back to public key
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(decodedPublicKey);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey pubk = keyFactory.generatePublic(pubKeySpec);
And got InvalidKeyException and lengthTag is TOO BIG.. Any one can tell what is the problem while reading back??
Thanks
Ameriwhile((s = br.readLine()) != null)
{ sb.append(s + "<br>");
//Store the file contents in the output string
output = sb.toString();Hi,
Ouch! Your extra data is probably coming from the <br>s. the 'b' and 'r' are being Base-64 decoded and producing extraneous bytes. I'm not sure why you have the <br> in there, but try removing it an see what happens. Good luck. -
Reading fields from a text file
Hi, I'm fairly new to this so bear with me.
This is for an assignment - the idea is to cretae an online system for booking seats at a cinema - haven't got past the login stage yet?
I've got an applet that needs to read in a field from a text file.
I'm using the StringTokenizer function.
I've put a test in to check that the applet can find the file, which seems to be ok.
However, it's not reading from the file.
Te file is a simple text file - fields are seperated by a comma and a space.
Any ideas?
Please help as this is quite urgent.
Prototype Code is below
public class cinema extends Applet implements ActionListener, ItemListener{
private List ActionList;
private int listIndex;
TextArea t = new TextArea(5, 30);
private Button gobutton, writebutton, login, logout;
private PrintWriter suggestfile;
TextField Userid, password, enterField;
private int count, checkuser;
private BufferedReader firstn;
File myFile = new File("e:\\Ian\\Unistuff\\2nd Year\\se2\\cinema2\\src\\cinema2\\member.txt");
//Construct the applet
public cinema() {
enterField = new TextField("Please enter user ID and Password");
enterField.setEditable(false);
add(enterField);
Userid = new TextField(3);
add(Userid);
password = new TextField(10);
password.setEchoChar('*');
add(password);
//Initialize the applet
public void init() {
BorderLayout borderLayout1 = new BorderLayout();
//some code ommitted
t.setEditable(false);
add(t);
gobutton = new Button("Go!");
add(gobutton);
gobutton.addActionListener(this);
public void actionPerformed(ActionEvent event) {
if (event.getSource() == gobutton) {
try {
firstn = new BufferedReader( new FileReader(myFile));
catch (IOException e) {
t.setText("Member database missing - please contact Chairperson");
return;
try {
String line1;
boolean found = false;
while (( ( line1 = firstn.readLine() ) != null) && (! found))
{StringTokenizer token1 = new StringTokenizer (line1, " ,");
String user = token1.nextToken();
if (Userid.getText().equals(user))
{ found = true;
t.setText("Hello");
firstn.close();
catch (IOException e) {
System.err.println("Error Reading File " + myFile + ": " + e.toString());
Here's the text file:
Ian, Dodson, 001, rubbish
Joe, Bloggs, 002, medway
Bill, Smith, 003, unique
Guest, , Guest,
To test that it is working, it should just put a message in the Text Area, but nothing happens when you press the "go" button.1. Your applet will not work, because it is trying to
read file from local disk.
2. This task can be solved by simple CGI script
(which is much more common and universal thing than
java), so you do not need to use java if you want to
send 3 lines to a server.
3. See examples and read some books.1. Stated the obvious.
2. This is a java forum, not Perl.
3. Pathetic and patronizing.
Very helpful. -
How to read characters from a text file in java program ?
Sir,
I have to read the characters m to z listed in a text file .
I must compare the character read from the file.
And if any of the characters between m to z is matched i have to replace it with a hexadecimal value.
Any help or suggesstions in this regard would be very useful.
Thanking you,
khurramHai,
The requirement is like this
There is an input file, the contents of the file are as follows, you can assume any name for the file.
#Character mappings for Japanese Shift-JIS character set
#ASCII character Mapped Shift-JIS character
m 227,128,133 #Half width katakana letter small m
n 227,128,134 #Half width katakana letter small n
o 227,129,129
p 227,129,130
q 227,129,131
r 227,129,132
s 227,129,133
t 227,129,134
u 227,129,135
v 227,129,136
w 227,129,137
x 227,129,138
y 227,129,139
z 227,129,142
The contents of the above file are to be read as input.
On encountering any character between m to z, i have to do a replacement with a hexadecimal code point value for the multibyte representation in the second column in the input file.
I have the code to get the unicode codepoint value from the multibyte representation, but not from a file.
So if you could please tell me how to get the characters in the second column, it would be very useful for me.
The character # is used to represent the beginning of a comment in the input file.
And comment lines are to be ignored while reading the file.
Say i have a string str="message";
then i should replace the m with the unicode code point value.
Thanking you,
khurram -
Reading Data From A Text File via AppleScript
Here is my question. I have a text file I need to read data from....this is what the text file looks like opened in text editor:
"SLUG
, 06/16/06, APPLE COMPUTER INC , 69x8.50, jondnotin
now what I need to do is get the 69 and the 8.50 as seperate variables...now every file that is going to be read is setup the same with different information but the data type is the same and in the same order. So what syntax do I need to read this file and set thoes two numbers to variables? Thanks!
PowerMac G5, iBook G4, Intel MacMini, PowerMac G3 B&W, iMac DV Blueberry Mac OS X (10.4.7)Hello
You where right for the file structure.
I think that it is a complementary reason to locate the data whithout assuming that it sit in paragraph x or y.
The trailing script get rid of that and allow to grab values from a file containing more than a single entry.
--[SCRIPT]
set leChemin to "Macintosh HD:Users:yvankoenig:Desktop:_testfile.txt"
set {val1, val2} to my decipher(read file leChemin, "APPLE COMPUTER INC , ")
display dialog "" & val1 & return & val2
-- -+-+-+-+-+-+-+-
on decipher(t, d)
set {oTID, AppleScript's text item delimiters, texte} to {AppleScript's text item delimiters, d, t}
set {texte, AppleScript's text item delimiters} to {text item 2 of texte, ","}
set {texte, AppleScript's text item delimiters} to {text item 1 of texte, "x"}
set {v1, v2, AppleScript's text item delimiters} to {text item 1 of texte, text item 2 of texte, oTID}
return {v1, v2}
end decipher
-- -+-+-+-+-+-+-+-
--[/SCRIPT]
Yvan KOENIG (from FRANCE vendredi 8 septembre 2006 20:38:46) -
Shell scripts to read data from a text file and to load it into a table
Hi All,
I have a text file consisting of rows and columns as follows,
GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL005675 000001 000000 000000 000000 000000 000000 000001 My requirement is that, i should read the first 3 columns of this file using a shell script and then i have to insert the data into a table consisting of 3 rows in oracle .
the whole application is deployed in unix and that text file comes from mainframe. am working in the unix side of the application and i cant access the data directly from the mainframe. so am required to write a script which reads the data from text file which is placed in certain location and i have to load it to oracle database.
so I can't use SQL * loader.
Please help me something with this...
Thanks in advance.1. Create a dictionary object in Oracle and assign it to the folder where your file resides
2. Write a little procedure which opens the file in the newly created directory object using ULT_FILE and inside the FOR LOOP and do INSERTs to table you want
3. Create a shell script and call that procedure
You can use the post in my Blog for such issues
[Using Oracle UTL_FILE, UTL_SMTP packages and Linux Shell Scripting and Cron utility together|http://kamranagayev.wordpress.com/2009/02/23/using-oracle-utl_file-utl_smtp-packages-and-linux-shell-scripting-and-cron-utility-together-2/]
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
I'm attempting to write a Combat Converter for a popular online game called Ogame. I'm attempting to read a text file that contians something similiar to the sample of the text file I have provided below. What I want to take out from the file is the first and last time a line that begins with Type and Num that shows up for the attacker and defender. However I'm having trouble figuring out how write it so that it does not take it out for the rest of the lines that start with Type and Num. Do you have any suggestions on how I should go about do so?
Attacker 1
Weapons:+10% Shields:+10% Armour:+10%
Type S.Cargo L.Cargo L.Fighter H.Fighter Cruiser B.Ship Col. Ship Recy. Esp. Probe Bomber Dest. Rip Battlecr
Num 1 1 1 1 1 1 1 1 1 1 1 1 1
Weapon 5 5 55 165 440 1.100 55 1 0 1.100 2.200 220.000 770
Shields 11 27 11 27 55 220 110 11 0 550 550 55.000 440
Armour 440 1.320 440 1.100 2.970 6.600 3.300 1.760 110 8.250 12.100 990.000 7.700
Defender 1
Weapons:+10% Shields:+10% Armour:+10%
Type S.Cargo L.Cargo L.Fighter H.Fighter Cruiser B.Ship Col. Ship Recy. Esp. Probe Bomber Sol. Sat Dest. Rip Battlecr Miss. L.Laser H.Laser Gauss Ion.C Plasma S.Dome LS.Dome
Num 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Weapon 5 5 55 165 440 1.100 55 1 0 1.100 1 2.200 220.000 770 88 110 275 1.210 165 3.300 1 1
Shields 11 27 11 27 55 220 110 11 0 550 1 550 55.000 440 22 27 110 220 550 330 2.200 11.000
Armour 440 1.320 440 1.100 2.970 6.600 3.300 1.760 110 8.250 220 12.100 990.000 7.700 220 220 880 3.850 880 11.000 2.200 11.000
The attacking fleet fires a total of 18 times with the total power of 1.059.543 upon the defender.
The defender's shields absorb 18.910 damage points.
The defending fleet fires a total of 33 times with the total power of 1.922.677 upon the attacker.
The attacker's shields absorb 38.730 damage points.
Attacker 1
Type B.Ship Col. Ship Rip
Num 0 0 1
Weapon 1.100 55 220.000
Shields 220 110 55.000
Armour 6.600 3.300 990.000
Defender 1
Type S.Cargo L.Cargo L.Fighter H.Fighter Cruiser B.Ship Col. Ship Esp. Probe Bomber Dest. Rip Battlecr Miss. L.Laser Ion.C S.Dome LS.Dome
Num 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
Weapon 5 5 55 165 440 1.100 55 0 1.100 2.200 220.000 770 88 110 165 1 1
Shields 11 27 11 27 55 220 110 0 550 550 55.000 440 22 27 550 2.200 11.000
Armour 440 1.320 440 1.100 2.970 6.600 3.300 110 8.250 12.100 990.000 7.700 220 220 880 2.200 11.000
The attacking fleet fires a total of 11 times with the total power of 2.276.933 upon the defender.
The defender's shields absorb 17.510 damage points.
The defending fleet fires a total of 47 times with the total power of 9.540.458 upon the attacker.
The attacker's shields absorb 15.761 damage points.
Attacker 1
Type Rip
Num 0
Weapon 220.000
Shields 55.000
Armour 990.000
Defender 1
Type S.Cargo B.Ship Esp. Probe Bomber Dest. Rip Battlecr S.Dome LS.Dome
Num 0 0 0 0 0 0 0 0 0
Weapon 5 1.100 0 1.100 2.200 220.000 770 1 1
Shields 11 220 0 550 550 55.000 440 2.200 11.000
Armour 440 6.600 110 8.250 12.100 990.000 7.700 2.200 11.000
The battle ends draw.
The attacker has lost a total of 10.178.000 units.
The defender has lost a total of 1.836.800 units.
At these space coordinates now float 1.776.210 Metal and 1.413.954 Crystal.I'm attempting to write a Combat Converter for a
popular online game called Ogame. I'm attempting to
read a text file that contians something similiar to
the sample of the text file I have provided below.
What I want to take out from the file is the first
and last time a line that begins with Type and Num
that shows up for the attacker and defender....Please define "take out from the file". Do you want to read and store just these lines?
Or do you want to remove these lines from the file and rewrite the file without these lines?
/Pete -
Applescript wont use a value from a text file as a number
I want to perform math operations on a value (0.0092926025390625) that is stored in a text file, i have no problem getting it into the applescript but it says "applescript error cant make "0.0092926025390625" into a number" i know that i am inputting the correct value but it still wont work.
This is just an example code but it does the same thing.
set csv to choose file with prompt "select a file"
read csv
set csv to result
set var1 to word 1 of paragraph 2 of csv
set var1 to var1+1
I get the error on the last lineSure...
set var1 to word 1 of paragraph 2 of csv
by definition, 'words' are string/text objects.
set var1 to var1+1
You can't add integers to strings. Sure, you see the string as being a series of digits, but they could just as easily be letters, symbols, or any other characters. How would you add 1 to "hello", for example?
All is not lost, though. You just need to give AppleScript a hint:
set var1 to (word 1 of paragraph 2 of csv) as number
Now it will read the text and attempt to coerce it to a number. Once it's a number you can add 1 to it.
Maybe you are looking for
-
How to build an .exe for cFieldPoint on a PC ?
Hi all, A couple of weeks ago I installed a system with a compact FieldPoint running a in RT mode (cFP 2020 and LV 7.1.1). To load the .exe on the cFP, I connected my PC to the cFP (ethernet), selected the cFP as execution target for LabVIEW and then
-
If your web pages are loading up slowly....This helped me out!
Mac OS: Long delay before webpages load, then load suddenly at normal speed Last Modified: April 20, 2010 Article: TS2296 Old Article: 106799 Symptoms When trying to access a website via its DNS name, such as www.apple.com, there may be a delay that
-
How to pass a multidimensional array to an Oracle procedure?
How can I pass a multidimensional array to oracle array? Thanx in anticipation,
-
Any way I can play music on 15" rMBP with lid closed?
Hi everyone, I'm enquiring if I can play music on my 15" retina Macbook Pro while it is asleep. I have an iPhone 5 I can listen to music on, but I've recently found that the sound is so much better if I plug my headphones into my Mac as it gives a fu
-
Quckly turn Data Services on and off
Does anyone know of a way to set up the 9330 Curve to quickly turn data services off or on? When in the office, I want the phone to be on, but not data services. I wish there were a way to set up a smartkey to turn off or on data services. Any ide