Text File to Table
Hi,
I need to Convert a text file in a specific format to table.
Please find the attachment for the text file.
the table contains columns Section, Address, Data, Attribute.
Anybody please share me a sample VI to implement the above.
-mfp.
Attachments:
ADC1.txt 1 KB
Please try to understand what smercurio told you : We can help you learn how to use LabVIEW, but we are not here to help you do your home work.
If you want help, you should show us what you have attempted yet : attach an example of your code. This will help us understand where you are stuck. If you don't, you will send us a very strong negative message.
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Similar Messages
-
How to get current month from filename and bulk insert from text file into table?
I set up some dynamic SQL to help my bulk copy data from a text file to a table. This works fine for files that come in every day; I get the previous day’s data, based on the file name that’s placed
in the folder. That’s why I’m using the ‘-1’. The dates will look like this: '20140131', so I'm using type 112.
declare @fullpath1 varchar(1000)
select @fullpath1 = '''\\system.local\ms\london\FTP\' + convert(varchar, getdate()-1, 112) + '_INDEXPRICES_EOM.SPC'''
declare @cmd1 nvarchar(1000)
print (@cmd1)
select @cmd1 = 'bulk insert [dbo].[SB_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
print(@cmd1)
exec (@cmd1)
I think the syntax will be somewhat similar to this:
YEAR(date_column)=YEAR(getdate()) AND MONTH(date_column)=MONTH(getdate())
I’m not totally sure how to incorporate that into my current syntax.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.I tried a couple versions of this.
Declare @StartDate Date, @EndDate Date
Select @StartDate = convert(varchar, getdate()-28, 112), @EndDate = convert(varchar, getdate()-1, 112)
BEGIN
declare @fullpath1 varchar(1000)
select @fullpath1 = '''\\ms\london\FTP\' + ''' between ''' + Convert(Varchar(10), @StartDate, 101) + ''' and ''' + Convert(Varchar(10), @EndDate, 101) + '''_SP.SPC'''
declare @cmd1 nvarchar(1000)
print (@cmd1)
select @cmd1 = 'bulk insert [dbo].[SPBMI_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
print(@cmd1)
exec (@cmd1)
END
Here’s the string:
bulk insert [dbo].[SPBMI_Monthly] from '\\ms\london\FTP\' between '02/03/2014' and '03/02/2014'_SP.SPC' with (FIELDTERMINATOR = '\t', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR='0x0a')
The error message I keep getting is:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'between'.
Msg 319, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
I feel like I’m already pushing this thing to the limit.
Maybe this last part isn’t possible.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Importing text file into table
hello
i have a text file which contains data like empno,date and one character . every day this file is updated with new records.
now i want this data to get inserted to a table, whenever new record has been appended to the text file
can i have query or some way to do this. i can do it through sql loader, but i will not have info when the data is appended to the text file.
pls help
thanks in advance
sdsreenivasIf you're on 8.0.3 (which has been desupported for a number of years), then SQL*Loader strikes me as your best option. You could write a batch process that re-loads the file periodically so you see changes or you could write a batch file that polls the timestamp for the file and calls SQL*Loader whenever it is updated.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Convert text file to table on Import
We have a lot of tables, that we'd like to maintain outside of FrameMaker (we're using FM9). I've been trying to figure out the best way to do it, and using the Import>File>Convert option seems like the best.
However, my question is what is best practice for the type of files we use? At first it seemed like using Excel and saving as a .csv or tab-delimited text file would be easiest. But there doesn't seem to be a .csv convert option and setting "," as the delimiter means we can't use commas inside the cell content. And it seems to import tab-delimited cells that contain a comma inside quotes.
It seems like the other option would be to use HTML for the table content. We are new to all this stuff, so using HTML would add to the learning curve, but I can push it through if it's best practice/will make the cleanest conversions. Or is there a way to use Excel that converts cleanly that I just haven't figured out?
Any thoughts would be appreciated!Last year, based upon a comment on this forum, I imported an Excel table into a structured FrameMaker document by copy. FrameMaker created the table and applied its own version of a structure. For example, row elements were named ROW, cell elements were named CELL, etc. Because my table structure used different names, I had to change them to make the structure valid. There may have been some subtle issues with the table element itself. It was not clean but it got the job done.
Regarding Michael's suggestion about XML, I DID try this once, and it worked fine. The exported XML from Excel was simple and clean. The XSLT was therefore easy to write. If you have lots of tables to do, this might be the best way to go. It may take some work to get it working correctly, but once it is, subsequent work will be minimized.
Regarding XML from Excel, I was using the old Excel format xls. I have not worked with the newer xlsx format, which IS based upon XML. If you are using xlsx, I would be sure to export as XML and not "save" as XML (not sure what the command would be) in order to avoid getting all the XML used in newer Excel to store formatting and other meta information.
Good luck. -
Hi all
I have a table LFA1 with headers LIFNR, MANDT, NAME1, NAME2, ...., . That table contains data and I need to create text file that collects all headers with all data, where each field is separated by TAB.
thanks for your help.Here is program for KNA1.
*"Table declarations...................................................
tables:
kna1. " General Data in Customer Master
*"Selection screen elements............................................
select-options:
s_kunnr for kna1-kunnr. " Customer Number 1
*" Type declarations...................................................
types:
begin of type_s_customer_details,
name like kna1-kunnr,
address like kna1-adrnr,
title like kna1-anred,
createdon like kna1-erdat,
createdby like kna1-ernam,
end of type_s_customer_details.
Internal table to hold General Data in Customer Master data *
data:
t_customer_details type table
of type_s_customer_details
with header line.
START-OF-SELECTION EVENT *
start-of-selection.
perform select.
*& Form select
This subroutine selects information from database and exports the *
data into presentation layer *
There are no interface parameters to be passed to this subroutine. *
form select .
select kunnr
adrnr
anred
erdat
ernam
into table t_customer_details
from kna1
where kunnr in s_kunnr.
if sy-subrc ne 0.
write : / 'DATABASE SELECTION FAILED'.
else.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'd:\customer_details.txt'
filetype = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
FILELENGTH =
tables
data_tab = t_customer_details
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
if sy-subrc <> 0.
write : / 'Upload Failed' , sy-subrc.
else.
write : / 'Upload Completed'.
endif.
endif.
endform. " SELECT -
Convert data in the text file to table in DBL
Hi guys
I wanted to convert data in text file which are in multiple rows and columns in DBL format to a table to b seen in labview as DBL format.
I had tried looking and working at the example but in vain , i just cant produce anything
pls help. or write me a short example..thanksAre you dealing with a table or an array. For an array, just use the Read spreadsheet file from the File I/O palette.
For a table, you will have to convert the number to a string and setting the appropriate precision and width, then write the 2-D string array to the table.
Message Edited by Ravens Fan on 05-20-2008 11:54 PM
Attachments:
Example_VI_BD6.png 3 KB -
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 -
Reading Text file & Updating table using PL SQL Procedure
Guys, I am trying to read data from a large text file which
contains tab delimited data. Based on success of validations, I
have to insert/update data in to table(s). Does any one has any
sample procedure to read data (tab delimted/comma seperated)
from a text file and write to database table? Your help is
greatly appreciated!Is there any particular reason why you're not using SQL*Loader
for this? Otherwise you would seem to be re-inventing the wheel.
rgds, APC -
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.
-
Generating Text file from table using Shell script
I am using KSH for generating and FTPing a text file from a table.
While generating Text file I am not getting my Column names in orderly manner.
q2="select COLUMN1||' '||COLUMN2||' '||COLUMN3 from table1;"
set pagesize 0
set head off
set trimspool on
set trimout on
set colsep ' '
set linesize 1500
set trimspool on
spool /ss/app11/oastss/reports/$file2
select 'COLUMN1'||' '||'COLUMN2'||' '||'COLUMN3' from dual;
$q2
spool off;
EOF
I am getting the result some what like below in text file
COLUMN1 COLUMN2 COLUMN3
MALLIK_ACCT 17-SEP-11 908030482
MALLIK_ACCT 17-SEP-11 908266967
MALLIK_ACCT 17-SEP-11 909570766
I want the format like below
COLUMN1........ COLUMN2 .... COLUMN3
MALLIK_ACCT ...17-SEP-11 .... 908030482
MALLIK_ACCT ...17-SEP-11 .... 908266967
MALLIK_ACCT ...17-SEP-11 .... 909570766
I put dots(.) for illustration purpose.
column data length may icrease some times . it shoudl automatically adjust column and data so that they are in alignment. thanks in advance.Mallik wrote:
Hi my question is to format the headers so that they will be in alignment with column data and readable.So you want to output a query as a fixed width format data file? How about this (rather than using scripts)...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 2 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),rec_tab(j).col_max_len,' ');
WHEN 12 THEN v_finaltxt := v_finaltxt||rpad(lower(rec_tab(j).col_name),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := v_finaltxt||rpad(nvl(v_v_val,' '),rec_tab(j).col_max_len,' ');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_n_val,'fm99999999999999999999999999999999999999'),' '),rec_tab(j).col_max_len,' ');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := v_finaltxt||rpad(nvl(to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),' '),greatest(19,length(rec_tab(j).col_name)),' ');
END CASE;
END LOOP;
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.csv file contains:
empno ename job mgr hiredate sal comm deptno
7369 SMITH CLERK 7902 17/12/1980 00:00:00800 20
7499 ALLEN SALESMAN 7698 20/02/1981 00:00:001600 300 30
7521 WARD SALESMAN 7698 22/02/1981 00:00:001250 500 30
7566 JONES MANAGER 7839 02/04/1981 00:00:002975 20
7654 MARTIN SALESMAN 7698 28/09/1981 00:00:001250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 00:00:002850 30
7782 CLARK MANAGER 7839 09/06/1981 00:00:002450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:003000 20
7839 KING PRESIDENT 17/11/1981 00:00:005000 10
7844 TURNER SALESMAN 7698 08/09/1981 00:00:001500 0 30
7876 ADAMS CLERK 7788 23/05/1987 00:00:001100 20
7900 JAMES CLERK 7698 03/12/1981 00:00:00950 30
7902 FORD ANALYST 7566 03/12/1981 00:00:003000 20
7934 MILLER CLERK 7782 23/01/1982 00:00:001300 10
The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required (this is currently coded for VARCHAR2, NUMBER and DATE) -
Seeking simple example pl/sql to create text file from table data
hello,
I am hoping someone can provide very simple example of creating a file on my local harddrive using a pl/sql program. The basic steps are as follows:
First, I store some text in a varchar2 variable like this:
1. select sometext into otextvar from mytable where recordid = 1;
Second, I want this text to become a file in my data directory:
2. c:\data\sometext.txt
The second step is where I need help.
Any suggestions are greatly appreciated.Use this function
It will create for you a file in your /home/oracle directory with sysdate name and will insert all table names in it
CREATE OR REPLACE PROCEDURE my_proc AS
CURSOR cursor1 IS
SELECT table_name from all_tables;
CURSOR cursor2 IS
SELECT sysdate from dual;
rec1 cursor1%ROWTYPE;
rec2 cursor2%ROWTYPE;
created_file_name VARCHAR2(100);
file_name utl_file.file_type;
BEGIN
OPEN cursor2;
LOOP
FETCH cursor2 INTO rec2;
EXIT WHEN cursor2%NOTFOUND;
created_file_name:=rec2.sysdate;
file_name := utl_file.fopen('/home/oracle', created_file_name,'W');
OPEN cursor1;
LOOP
FETCH cursor1 INTO rec1;
EXIT WHEN cursor1%NOTFOUND;
utl_file.putf(file_name, '%s\n',rec1.TABLE_NAME);
END LOOP;
utl_file.fclose(file_name);
END LOOP;
END my_proc;
SQL>exec my_proc; -
Import external text file into table in database using web form
I whant to import data from text delimited file located in os
into oracle table using web form.
I am using ORACLE DATABASE 8i, APPLICATION SERVER 9i
and ORACLE FORMS DEVELOPER AND FORMS SERVER 6i (Patch 2)
Is there anybody who know how can i do this?
Thank you!WebUtil 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.
-
How to write data to text file using external tables
can anybody tell how to write data to text file using external tables concept?
Hi,
Using external table u can load the data in your local table in database,
then using your local db table and UTL_FILE pacakge u can wrrite data to text file
external table
~~~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
UTL_FILE
~~~~~~~~~
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
Message was edited by:
Nicloei W
Message was edited by:
Nicloei W -
How to insert text file in a table (unix environment)
Hi All,
i am having a requirement that i need to insert a text file in table.
how can i do it. i am in unix environment.
NOTE:- for this i have to write a SQL*LOADER script (not a pl/sql unit)
Regards
HarshYou can use SQLDeveloper to help load data from a file into a table. With SQLDeveloper you can load data into an existing table by right clicking on the table on the connections tree and choosing import and selecting the file to import. If the table does not exist you can right click on the table folder and click import and the import process will allso create the table. You have the choice of a number of methods for importing the data, including SQL Loader, insert script, excuted sql, staging external table or permanent external table.
Joyce Scapicchio
SQLDeveloper Team -
Read and write from and to text file
Hi All,
I am trying to read some portion of a text file and make measurement and calculation with those numbers and write back to the same text file and also to a excel file. I need to create a 2 D array of 20 by 20 from the text file values and write to front panel table and to text file. but I am having problem with it, obviously I am new to this. Please help me. thanks much
~ JohnnyHi Lynn,
the requirement is to move C1 and C2 to each position that is given in the text file in steps and percentage value.
for example C1 has to go to first step (5%) and C2 has to go thru all steps, 5% to 95% , in 5 percent increment.
each 100 steps translates to 1 percent increment in the capacitor value.
at the end, I need to enter the measured data (values of C1 for each step, vesus all values of C2 for all steps) and enter them at the bottom of the text file's table where it starts at : "IMPEDANCE_REAL in Ohmone line per C1 position, containing all values for the different C2 positions" and do the same for where it says "IMPEDANCE_IMAGINARY in Ohmone line per C1 position, containing all values for the different C2 positions"
the reason I read the file twice, is that if it read it once, I couldn't connect it to spreadsheet string to array vi.
as you can see, I also like to use the write to measurement file and build table express vi's to display the table on the front panel and save the data to ni data file format so later I convert it to excel too.
any thoughts?
thanks for your help
~ Johnny
Attachments:
read from text2.vi 82 KB
Maybe you are looking for
-
Hi All, File to Idoc: Sender : Party : PT_ABC Business Service : BS_ABC Note : I provided the LS name(PARTABC) for BS_ABC Under Adapter Specific identifiers. Receiver : Business system (Without party) : BS_DEV_R/3 In the IDOC receiver communication c
-
Will changing Network name affect Time-capsule back up function
I finally managed to set up my time capsule with Mac support help. I didn't realize until this morning that I didn't want my network name to be my full name. I think I can change the network name easily enough through the airport function. But will t
-
Hi, We are currently looking to put in a bit of a ILCM to our BI system. We are on BW 7.0 and currently have no archiving in place. The main issue we would have when archiving is still being able to report on the data that is archived, and for this I
-
Enter formula in mass processing
Hi Experts, In transaction OB_GLACC12,I have to copy the contents from one field to another using the enter formula option. Kindly let me how the segment structure SKB1 can be read for further processing. Thanks in advance. Regards, Sridevi
-
Convert two dates difference to number of years, months and days
Post Author: gigimonu CA Forum: Formula I wanted to write a formula (if there is a function I can use) that can convert a date difference to total number of years, months and days example adate = 10/22/2006 ?xdate = current date - adate (answer shoul