Reading Text file or Database efficiently
Hi.
I have an option to read EMP names randomly from either text file or database . Can anyone tell me which one will be fast. I have to read more than 5000 names dynamically for my application and pick one name randomly.
Many thanks, Ravi
Hi quitte ,
Thanks for replying. I just want to pick names randomly from file or database to name each and every customer in my application dynamically.
For this, I created one table with Unique names and would like to design a code such that each customers will be named dynamically.
Any Suggestions or Advise?
Ravi
Similar Messages
-
Help needed in reading text file to database table
Hello experts,
i have to insert the values from the column of this text file and insert them in my database table.
I have done a few file to table insertions but i'm having some trouble with this one.
Any suggestions plz
thanks
liab_report 1.00 Page: 1
CDC:00537 / Mon Jun-21-2010 LIABILITY REPORT Mon Jun-21-2010 22:06:26
DRAW 1; SET 1; November 7, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 701040.00 0.00 660146.00 0.00 40894.00 0.00 0.00
Div3 1444128.00 0.00 1330056.00 0.00 114072.00 0.00 0.00
Div4 4711900.00 0.00 3889700.00 0.00 822200.00 0.00 0.00
6857068.00 0.00 5879902.00 0.00 977166.00 0.00 0.00
DRAW 2; SET 1; November 14, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 817817.00 0.00 817817.00 0.00 0.00 0.00 0.00
Div3 1687405.00 0.00 1611742.00 0.00 75663.00 0.00 0.00
Div4 3402100.00 0.00 3034200.00 0.00 367900.00 0.00 0.00
5907322.00 0.00 5463759.00 0.00 443563.00 0.00 0.00
DRAW 3; SET 1; November 21, 2009
TOTAL PAID ON TOTAL EXPIRED ON TOTAL FRAC OUTSTANDING
WINNERS 06/21/10 PAID 06/21/10 EXPIRED ROUND
DIVISION AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT AMOUNT
Div1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Div2 779933.00 0.00 769804.00 0.00 10129.00 0.00 0.00
Div3 1605548.00 0.00 1525104.00 0.00 80444.00 0.00 0.00
Div4 4891700.00 0.00 4256800.00 0.00 634000.00 0.00 900.00
7277181.00 0.00 6551708.00 0.00 724573.00 0.00 900.00Plz clarify whether u want to load text file as a file into database or value of this text file into database. If values are to be loaded from this text file, U can better format the text file and use SQL loader to load the file into database. By formatting the database, i mean remove the unnecessary headings and characters, kee only the values to be loaded idelimited by ' '(space) or ','(comma). Create a control file and load it into the target table.
-
Reading text file from database server in OA Page
Hi Guys,
I am trying to embed an applet with in an OA Page. The applet is used to mainly for showing Gantt chart. I have to pass my connection details from OA Page to applet, I dont pass directly the connection details to the applet so i am placing all the server details, user name and password in a text file on the database server.
So from the OA Page i have to read the contents of the file on the database server and pass them to the applet using the <PARAM> tag. My question is how to read the text file from the database server.Any Inputs?
Thanks in advance for your help.
Regards,
Nagesh Manda.If the file to be read is on the database, then it makes sense to use the pl/sql code to read the file. Make a call to this pl/sql code from page controller to get back the values.
--Shiv -
How to read text file efficiently?
I use CharBuffer to read text file:
private List<String> load() throws IOException {
final String B = "<BODY>";
final String E = "</BODY>";
List<String> docs = new ArrayList<String>();
for (File file : files) {
FileReader reader = new FileReader(file);
CharBuffer buffer = CharBuffer.allocate(BSIZE);
StringBuilder sb = new StringBuilder();
while (reader.read(buffer) != -1) {
char[] dst = new char[buffer.length()];
buffer.get(dst);
sb.append(dst);
buffer.clear();
String s = sb.toString();
System.out.println(file + ": " + s.length());
int start = 0;
int i, j;
while ((i = s.indexOf(B, start)) != -1) {
j = s.indexOf(E, i + B.length());
docs.add(s.substring(i + B.length(), j));
start = j + E.length();
//System.out.printf("%d %d %d%n", i, j, start);
return docs;
}The file size is 1324350, but the code say it is 772802.
What's wrong with this code?
I want to read text file as quickly as possible.
Is this code the right way to read file?
Should I use FileReader or nio Channel and ByteBuffer?
Any suggestions are welcome!You are reading the file as if it were encoded in UTF-16. Each character uses two bytes so you have half the number of characters as you had bytes.
The following code reads an entire file in one hit.
public static String readText(File file) throws IOException {
byte[] bytes = new byte[(int) file.length()];
DataInputStream dis = new DataInputStream(new FileInputStream(file));
try {
dis.readFully(bytes);
} finally {
dis.close();
return new String(bytes, "UTF-8"); // or whatever your file encoding is.
}But you can still have less characters than bytes if there are any non ASCII-7 characters. -
HOW TO IMPORT HUNDREDS OF TEXT FILE TO DATABASE AS TABLE
Hi,
I have hundreds of text files in my computer. Every text file includes records. I want to see these records in one table at the database. How can I do that?
thank you very much for help
ömer faruk akyüzlü
in TurkeyI have a standard template that my developers use for reading text files using External Tables . Each developer gets an external table to read in test data. The format the data in CSV format, but you could use others. The External Table points to a generic file name, such as "csv_data". They then just rename the file or create a link to it, depending on the OS.
My solution uses the Directory objects. The following can be put in a script and run passing the first argument as the developers name. It supports a csv file upto 15 columns, but you can expand it.
-- begin script
CREATE OR REPLACE DIRECTORY &1 as '/home/&1';
grant read on directory &1 to public;
alter session set current_schema=&1;
--drop table csv_data;
CREATE TABLE csv_data
col1 VARCHAR2(250),
col2 VARCHAR2(250),
col3 VARCHAR2(250),
col4 VARCHAR2(250),
col5 VARCHAR2(250),
col6 VARCHAR2(250),
col7 VARCHAR2(250),
col8 VARCHAR2(250),
col9 VARCHAR2(250),
col10 VARCHAR2(250),
col11 VARCHAR2(250),
col12 VARCHAR2(250),
col13 VARCHAR2(250),
col14 VARCHAR2(250),
col15 VARCHAR2(250)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY &1
ACCESS PARAMETERS
(RECORDS DELIMITED BY newline
NOBADFILE
NODISCARDFILE
NOLOGFILE
SKIP 0
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
RTRIM
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
col1 CHAR, col2 char,col3 char,col4 char,col5 char,col6 char,col7 char,col8 char,col9 char,
col10 char,col11 char,col12 char,col13 char,col14 char,col15 char
LOCATION (&1:'csv_data')
REJECT LIMIT Unlimited
NOPARALLEL
NOMONITORING
--end script -
Hi,
I'm using oracle 9i on a server , and microsoft iis 6.0 is running on other server,
I want to create a stored procedure, that read log file exist on iis server, and insert data on a table on oracle server.
I want this procedure to run on daily basis, updating table content, then I will use discoverer to create reports.
how can I do that?Best way to load data from text file to database is SQL*Loader.Actually in 9i the best way might be to use an External Table. This is much simpler to use than SQL*Loader because we can just issue a SELECT statement to get the data. SQL*loader is really only necessary when we have huge amounts of data and perfomance is critical.
Cheers, APC -
Can I save and read text files on a server that I host?
Hello everyone,
I am a java hobbiest. I was wondering if I set up my own server, running out of my house, could I have my applets save to my computer and read from my computer without having to learn JDBC and a DATABASE language. In other words could i just have my applet save and read text files from and to my server?
I'm trying to set up a sight for my 5th grade class where parents can log into. Thanks for your time.
Oh yeah, which is easier, learning how to set up a server or learning JDBC and a DATABASE language?
If you have any other good idease please tell me them
Thank you, BryanShort answer: This isn't gonna work
Long answer: For this to work, the first thing you're going to need is a static IP address and a DNS name registered -actually you don't necessarily need #2 but you're probably gonna want it and it's by far the easier of the steps.
As far as I know to get a fixed IP address you've either gotta be directly attached to a larger network (ie university network) or get a leased line from an ISP.
Once you've got that done come back to us. -
Read text file and insert into MySQL
Dears,
I need to read text file and then insert the data in the correct column in the MySQL database
example
I have the following text file:
field1=1234 field2=56789 field3=444555
field1=1333 field2=2222 field3=333555
and so on and so forth ,,note that all rows are identical and just the filed value is changed(there is a dilemeter between fields)
how can I read field1,field2 and field3 from text file and insert them in the correct table and column in the database.....
any help?????
thanks for your cooperation
Best RegarsSure.
Which part don't you understand?
1. Reading a text file
2. Parsing the text file contents.
3. Relational databases and SQL.
4. How to create a database.
5. How to connect to a database in Java.
6. How to insert records into the database in Java.
7. How to map Java objects to records in a database.
This is a pretty nice list. Solve complex problems by breaking them into smaller ones.
% -
USING WEBUTIL TO READ TEXT FILE INTO TABLE HANGS AFTER CERTAIN NUMBER OF RE
Dear
when we use webutil to retrieve data from text file into database table
(using text_io) it hangs after certain number of records ( approx. 1300
records) while the total number of records to be inserted in the table exceeds
12000 records while it works properly on forms6i with the normal text_io any
help please...?
thanks and regardsWebUtil uploads the files as Binary - so yes you could have some issues if you have a Unix host - however, that would only mean that there is an extra character to trim off of the end of the line read by Text_io.
-
Reading text file to JEditorPane
Hi,
I'm trying to read text file to JEditorPane and it works but first line is always missing. Here is the code for reading:
try {
in = new BufferedReader(new FileReader(filePathIn));
while ((lineIn = in.readLine()) != null) {
editorPane.read(in, new Object());
} catch (IOException ie)...Any suggestions?in.readLine is changing the input stream position.
Do this instead:
FileInputStream in = new FileInputStream(filePathIn);
while (in.available() != 0)
editorPane.read(in, new Object()); -
How to extract data from text file to database table
Hi ,
I am trying to upload data in text file to database table using GUI_UPLOAD function .what would be the program for that.
thanks in advance.Hi,
I don't think you have a standard sap program to upload data from file to database table...
Instead you can create a custom program like this..
DATA: T_FILEDATA(1000) OCCURS 0 WITH HEADER LINE.
DATA: T_ZTABLE LIKE ZTABLE OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEST.TXT'
tables
data_tab = T_FILEDATA
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.
LOOP AT T_FILEDATA.
T_ZTABLE = T_FILEDATA.
APPEND T_ZTABLE.
ENDLOOP.
MODIFY ZTABLE FROM TABLE T_ZTABLE.
COMMIT WORK..
Thanks,
Naren -
i am not able to read text file in 10g forms. using webutil.pll and webutil.lib
here i posted the code . i am not getting message 2, client_text_io.fopen is not working what could be the reason.
DECLARE
in_file client_TEXT_IO.FILE_TYPE;
V_LINE_COUNT number;
linebuf VARCHAR2(1800);
V_var1 varchar2(80);
V_var2 varchar2(80);
V_var3 varchar2(80);
V_var4 varchar2(80);
V_var5 varchar2(80);
filename VARCHAR2(30);
l_var number;
blnRet BOOLEAN;
begin
DELETE FROM NIRU_TEMP;
:file_path:=LTRIM(RTRIM(:file_path));
MESSAGE('1');
in_file := client_text_io.fopen(UPPER(:file_path),'r');
MESSAGE('2');
loop
V_LINE_COUNT := V_LINE_COUNT + 1;
client_text_io.get_line(in_file,linebuf);
MESSAGE('5');
V_var1 := substr(linebuf,1,(instr(linebuf,',')-1)) ;
MESSAGE('6'||V_VAR1);
MESSAGE('6'||V_VAR1);
l_var := length(v_var1);
V_var2 := substr(linebuf,l_var+2,(instr(linebuf,','))) ;
--V_var3 := substr(linebuf,15 ,10 );
V_var2 :=LTRIM(RTRIM(V_var2));
MESSAGE('6'||V_var2);
MESSAGE('6'||V_var2);
:p_id := v_var1;
:p_desc :=v_var2;
--IF V_var2 = '' THEN
--V_var3 :='';
--else
--V_var3 := TO_NUMBER(V_var2) ;
--end if;
--V_var5 := substr(linebuf,26 ,70 );
INSERT INTO NIRU_TEMP VALUES (V_var1,V_var2);
client_text_io.new_line;
:System.Message_Level := '20';
commit;
:System.Message_Level := '0';
--<<end_loop>>
--null;
next_record;
end loop;
client_TEXT_IO.FCLOSE(in_file);
exception
WHEN OTHERS THEN
MESSAGE('ERROR'||SQLCODE||' '||SQLERRM);
--exit;
end;Hello Francois,
You have a solution for this problem?
I have a problem like this. While reading a text file, such as size of 7MB, long, between 15-30 minutes.
See...
declare
arq client_text_io.file_type;
linha varchar2(800);
v_total number := 0;
v_icms number := 0;
begin
:valor_total := 0;
:valor_icms := 0;
arq := client_text_io.fopen(:arquivo,'r');
loop
client_text_io.get_line(arq,linha);
if substr(linha,1,1) = '1' then
v_total := v_total + (to_number(substr(linha,302,13))/100);
v_icms := v_icms + (to_number(substr(linha,262,13))/100);
end if;
end loop;
client_text_io.fclose(arq);
exception
when no_data_found then
:valor_total := v_total;
:valor_icms := v_icms;
message('Realizado com sucesso!');
message('Realizado com sucesso!');
end; -
How to read text file content in portal application?
Hi,
How do we read text file content in portal application?
Can anyone forward the code to do do?
Regards,
AnaghaCheck the code below. This help you to know how to read the text file content line by line. You can display as you require.
IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
IResourceContext resourceContext = new ResourceContext(user);
String filePath = "/documents/....";
RID rid = RID.getRID(filePath);
IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
InputStream inputStream = resource.getContent().getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = reader.readLine();
while(line!=null) {
line = reader.readLine();
//You can append in string buffer to get file content as string object//
Regards,
Yoga -
How can I read text files from LAN if I only know the hostname?
I'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
<p>1. How can I read text files from LAN if I only know the hostname, or IP address?
<p>2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.
(ex. how can I read the 120th line?)
<p>Please help!
<p>sorry for the bad englishI'm new in Java Developing, and dont know the written classes yet. I need help, how to do the following steps?
1. How can I read text files from LAN if I only know the hostname, or IP address?You need to know the URL of the file. You need to know the hostname, port, protocl and relative path.
The hostname is server, not file.
2. How to read lines from text files without read all lines from the beginning of file, just seek to a position.Use the seek() to get to a random byte.
(ex. how can I read the 120th line?)The only way to find the 120th line is to read the first 120 lines. You can use other file formats to find the 120th line without reading the whole file but to need to be able to detremine where the 120th line is -
How to read text file contain chinese character ?
Hi XI Expert,
I have scenario to read text file contain Chinese Character using sender file adapter. but every i was check from sxmb_moni all the chinese character looks different. and also the target file also i has changes.
Please advise me how to maintaine the chinese character in PI 7.0 SP17.
Thank You and Best Regards
FernandHi,
Refer these threads..
Receiver file adapter corrupting characters
Problem in converting special characters in input text file
Here is one more useful guide..
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42
Regards,
Sarvesh
Edited by: Sarvesh Singh on Nov 17, 2008 3:47 PM
Maybe you are looking for
-
Update rule from one Cube to another
Hello Gurus! Here is the situation :- We have a IC ZCube1. This cube contains order data at schedule line level. It contians an IO for each Hold Status (in all 10 ) . IO has value 'X' if it is active else blank. 1 order line item can have multiple h
-
I Need Help!!! Nokia 6730c.
Hello! I have a problem with my Nokia 6730. I bought it 2 weeks ago. Phone for some reason very slow, long reacts to pressing buttons, and for some unknown reason, restarts and resets the time. I can not install it on third-party applications, for ex
-
I need to update my ARD admin from 3.6 to 3.7 but client is at 3.8 and it errors out. How do I work around this?
-
When I try to post a form I get the message: Acrobat unable to connect to your email program. Using: Outlook Express or Thunderbird, Windows XP Pro SP3
-
HI, For all who is using BTDF this is a wonderful script to do silent BTDF installation. After using that script i got below exception.Do any one have any ideas of what this exception means from BTDF side. Am using BTDF 6.0 version,BTS 2013 r2 versio