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
Similar Messages
-
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. -
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. -
Hi i am new to labview
I want to extract data from a text file and display it on the front panel.
How do i proceed??
I have attached a file for your brief idea...
Attachments:
extract.jpg 3797 KBRoopeshV wrote:
Hi,
The below code shows how to read from txt file and display in the perticular fields.
Why have you used waveform?
Regards,
Roopesh
There are so many things wrong with this VI, I'm not even sure where to start.
Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
Not using Read From Spreadsheet File.
Use of local variables to populate an array.
Cannot insert values into an empty array.
What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
Also, how does this answer the poster's question? -
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. -
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) -
Reading data from a text file but can't use the data outside of the function.
I am trying to load a variable from data in a text file.
I can read the text file fine but the variable data seems
only to be available with in the function that reads it.
I need to use the variable data outside of the function.
Does anyone have any suggestions to work around this issue?
This is the actionscript code i'm using.
var pathVars= new LoadVars();
pathVars.onLoad=function(ok) {
if(ok)
trace("Loading");
path_var=pathVars.path;
trace("This is within the function "+path_var);
pathVar0="This is within the function... "+path_var;
Yet the path_var is available here fine.
pathVars.load("mypath.txt");
This is where the path_var becomes undefined
trace("This is outside the function... "+path_var);
pathVar1="This is outside the function... "+path_var;
This
is a download link for the FLA zip file
This
is a demo of the script loading the text fileThe external traces are being executed before the file is
loaded. -
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 -
Retrieve data from a text file and insert in table
hi,
i am writing an application which when executes would creates a user table and populates it with the data i.e. username and passwords taking it from a text file.
i would like to know if anybody can help as to how can i retreive the user name and password for every insert statement that will be fired to populate the user table.
thanks in advance for the helpfor csv try a little search:
http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=csv+import
search for ini files:
http://search.java.sun.com/Search/java?qt=ini+file&col=javafrm&rf=0&qp=%2Bforum%3A31
hope this helps
tobias -
Compare data from 2 text files and output match
Hi all,
I need some advice.
Firstly in BinaryCode.txt the data is as such:
Replace BinaryCode0 1 0 0 0 0 0 0 0 0
Replace BinaryCode0 1 0 0 0 0 0 0 0 1
Replace BinaryCode1 1 1 1 0 1 1 1 1 1
Replace BinaryCode1 1 0 0 0 0 0 0 0 0
the first line in the text file is the header. So I need to check if the names in the second column (BinaryCode0 or BinaryCode1)appear in the Timed_Sets.txt file.
The data in Timed_Sets.txt is as such:
BinaryCode0,6,40,.........................
BinaryCode0,7,40,.........................
BCName1,0,20,.............................
BCName1,1,20,.............................
For example since BinaryCode0 is a match I will output the entire row in Timed_Set.txt to another array.
I have been working on a program but I don't get the expected output.
The text files and the VI are attached.
I appreciate your kind assistance in the matter.
Thank You
Regards
kart
Solved!
Go to Solution.
Attachments:
BinaryCode.txt 1 KB
compare text files.vi 15 KB
Timed_Sets.txt 2 KBIf I understood correctly what the output should be then what you basically need to do is to walk through the column in BinaryCode.txt and for each unique value pull out the corresponding rows from Timed_Sets.txt. There's a variety of ways to do this, depending on how much data you have and whether or not you can use any kind of prior knowledge as to the actual file content (such as the names of the keys being searched). Attached is one way. Modify as needed.
Attachments:
compare text files MOD.vi 27 KB -
Reading data from a text file to the MIDP RMS.
Sorry if this is a bit 2 newbie...
What I want to do is read a data file(ie csv), from windows and write the data into the record store.
My main idea is to store the recordstore files on windows and updated them from the text windows files and autosync the recordstores between windows and my palm...
Is this possible? If so is it a crappy way to do it... would there be a better wayHi Stephen:
Bundle the readme.txt, CSV file etc. with the jar that contains your MIDlet. Pretty clever way to initialize a datastore.
public void startApp() throws MIDletStateChangeException
// retrieve the contents of a resource file
System.out.println("Retrieving the resource file - readme.txt");
System.out.println("--------------------------------------------");
InputStream is = this.getClass().getResourceAsStream("readme.txt");
try {
if ( is != null ) {
int ch;
while ( (ch = is.read()) != -1) {
// print out the contents of the readme file
System.out.print((char) ch);
// or move the char in a byte array for the datastore
// I know you get the picture
is.close();
} catch (IOException e) {
System.out.println(e);
} -
Okay so basically i need to read some text from a file, and display it in a JTextArea. My problem is that when i read the data and display it, its all in one big long line. e.g:
in text file:
Hi
Hi
Hi
Hi
in textarea:
HiHiHiHi
I was wondering if it is possible to use some kind of a method that determines when reading the file if its at the end of a line or not, then create a new line.
this is part of my code:
chooser is a JFileChoose object.
File theFile = new File(chooser.getSelectedFile().getPath());
FileReader reader = new FileReader(theFile);
BufferedReader buffer = new BufferedReader(reader);
String ss;
String aa = "";
while((ss = buffer.readLine()) !=null) {
aa = aa + ss;
text.setText(aa);
reader.close();
//Rest of program continues hereHii , I think this will help you ,,,
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
class Test5 extends JFrame
JPanel mainPane;
JButton doTestBtn = new JButton("Press");
JTextArea show = new JTextArea(6,6);
JFileChooser choose = new JFileChooser();
public Test5()
GridLayout gl = new GridLayout(1, 2);
gl.setHgap(10);
gl.setVgap(10);
mainPane = new JPanel();
JPanel side1 = new JPanel();
JPanel side2 = new JPanel();
mainPane.add(side1);
mainPane.add(side2);
side1.add(doTestBtn);
side1.add(show);
doTestBtn.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
doTestBtnAction();
private void doTestBtnAction()
try
int tt = choose.showOpenDialog(Test5.this);
if(tt == JFileChooser.APPROVE_OPTION )
File file = choose.getSelectedFile();
FileReader reader = new FileReader(file);
BufferedReader buffer = new BufferedReader(reader);
String ss;
String aa = "";
while((ss = buffer.readLine()) !=null)
aa = aa + ss;
show.append(aa);
reader.close();
}catch(IOException ex)
private void createGUI()
getContentPane().add(mainPane);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200,100);
pack();
setVisible(true);
private static void createAndShowGUI()
Test5 rn = new Test5();
rn.createGUI();
public static void main(String[] args)
javax.swing.SwingUtilities.invokeLater(new Runnable()
public void run()
createAndShowGUI();
}Thanks ,
sb -
How to read data from a text file
I have saved a text file on my hard drive, and would like to read the file. Once read I would like to copy it to another file. I think I am suppose to use the BufferedReader, and FileReader classes. I am not sure what sequence to follow in order to do this. Could some one give me some feed back on what is needed, and in what sequence to perform this task?
Where do I store my file within my Platform(Eclipe), in order to read or access the file. Whenever I use the declaration below. I get an FileNotFoundException. I understand the code, but am not sure where to store the file, so that the line of code below will recognize it..
FileReader in = new FileReader("data1.txt");
BufferedReader a = new BufferedReader(in); -
Reading data from a text file into a JTextField
So I am writing a program that will write to and read from a large database. I was hoping to allow a graphical interface for the reading of the data, but I keep getting an error;
Incompatible Types
Found: java.lang.string
Required: javax.swing.JTextField
Now I know that this means the are incompatible (like trying to give an integer variable a string command) but I can't find any documentation on how to change the String into a JTextField format. I've found several references on how to do the reverse, but with my lack of JAVA knowledge I can't seem to get it to work. (Tried things like getText() and the like, but just end up with more errors).
*On a side note, is there an easier way to go about reading a file line by line, with each line going into a seperate JTextField, than;
BufferedReader r;
try {
r = new BufferedReader(new FileReader("C:\\temp\\test.txt"));
while ((thisLine = r.readLine()) != null) {
array[i] = thisLine;
i = i + 1
and then assigning each JTextField it's own array slot?*
Thank you for your help.Try something like this for putting the text in a control:
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class Junk{
String[] s = {"This is String 1.", "This is String 2.", "This is String 3."};
Junk(){
public void makeIt(){
JFrame j = new JFrame("Forum Junk");
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.setPreferredSize(new Dimension(300, 200));
JTextArea jt = new JTextArea();
p.add(jt);
j.add(p);
jt.setText(s[0]);
jt.append("\n\r"+s[1]);
jt.append("\n\r"+s[2]);
j.pack();
j.setVisible(true);
public static void main(String[] args) {
Junk j = new Junk();
j.makeIt();
}Depending on your design you may be able to do away with your array and append the text directly to the JTextArray after each line is read.
Maybe you are looking for
-
How should I debug a PVM that is crashing & rebooting too fast ?
I have a newly created oel4u6 PVM that appears to be starting but then crashing & rebooting too fast and I don't know how to best debug it. The vm is a P2V'ed oel4u6 HP Blade that successfully boots as a HVM but I can't seem to get it to fully start
-
When I use a file dialog with a datalog type wired to it, it only list all files with the same datalog type, that's ok. But then i open one of them, when I try to read another file, the first one is no longer in the list. Do you know why, and how to
-
If anyone knows other reference than Bayross, pls tell me. The example in Bayross is very difficult to unberstand. it is very urgent. pls reply. Regards Subrata
-
More than one h:form tag?
Hi, I have my pages setup with a header and footer page. So that each page does this: home.jsp: <%@ include file="/includes/header.jsp" %> <%@ include file="/includes/footer.jsp" %>Now, both the header.jsp and footer.jsp pages use h:commandLink tags
-
Iphoto problem please help!
right i have a problem with my iphoto!! i came on to my MacBook Pro a couple of days ago and all my photos have gone of my iphoto i do not have any of my files backed up is there anyway i can retrive my photos as i had well over 3000 photos and all m