Reading data from a file txt and inserting into table
I have a text file and have uploaded data in this text file in an internal table,the data is normally placed online and I managed to recover most of the data, but I have problems by inserting a few conditions
OK, well it goes like this.
I got the right reailer id,
Well, I have a table with all the columns in the file. Now it I'll try to throw it out as simple as I can
Reseller 1
column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1
===============
Total 0 0 0 0 0 0 0
-------------------------------------
Distributor 2
column 1 column 1 column 1 column 1 column 1 column 1 column 1 column 1
===============
X 1123... .. .. .. .. ..
234 Y... .. .. .. .. ..
Total 23... .. .. .. .. ..
see the problem is I have to associate the retailer number to their corresponding x and y and also not all retailers have values X and Y
The remains of standard file format but only the values of the columns may change, but they must be inserted in the table according to the number of retailers.
U understand what I mean...
How about you, including both terminal number (just for the fun of it... hehe!):
SQL> ed
Wrote file afiedt.buf
1 select retailer_no, terminal_no, retailer_name, val1, val2, val3, val4, val5, val6, val7, val8, val9, val10
2 from (
3 select case when retailer_no is null then lag(retailer_no, decode(val1, 'Loto', 1, 'Inst Tk', 2, 3)) over (order by line_no) else null end as retailer_no
4 ,case when terminal_no is null then lag(terminal_no, decode(val1, 'Loto', 1, 'Inst Tk', 2, 3)) over (order by line_no) else null end as terminal_no
5 ,case when retailer_name is null then lag(retailer_name, decode(val1, 'Loto', 1, 'Inst Tk', 2, 3)) over (order by line_no) else null end as retailer_name
6 ,val1, val2, val3, val4, val5, val6, val7, val8, val9, val10
7 from (
8 select rownum as line_no
9 ,case when regexp_like(line, '^Retailer Number:') then regexp_replace(line, '^Retailer Number: +([0-9]+).*$', '\1') else null end as retailer_no
10 ,case when regexp_like(line, '^Retailer Number:') then regexp_replace(line, '^.* Terminal Number: +([0-9]+).*$', '\1') else null end as terminal_no
11 ,case when regexp_like(line, '^Retailer Number:') then regexp_replace(line, '^.* Retailer Name: +(.*)$', '\1') else null end as retailer_name
12 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then trim(substr(line, 1, 15)) else null end as val1
13 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 1) else null end as val2
14 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 2) else null end as val3
15 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 3) else null end as val4
16 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 4) else null end as val5
17 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 5) else null end as val6
18 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 6) else null end as val7
19 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 7) else null end as val8
20 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 8) else null end as val9
21 ,case when regexp_like(line, '^( +Loto | +Inst Tk|Totals)') then regexp_substr(line, '[^ ]+', 16, 9) else null end as val10
22 from cdc_file
23 where regexp_like(line, '^( +Loto | +Inst Tk |Totals|Retailer Number:)')
24 )
25 )
26 where retailer_no is not null
27* order by 1, decode(val1, 'Loto', 1, 'Inst Tk', 2, 3)
SQL> /
RETAILER_N TERMINAL_N RETAILER_NAME VAL1 VAL2 VAL3 VAL4 VAL5 VAL6 VAL7 VAL8 VAL9 VAL10
---------- ---------- ------------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
10000 1000006 XXXX XXXX XX Default Location Totals 0.00 0.00 0 0.00 0 0.00 0 0.00 0
10000 1000008 XXXX XXXX XX Default Location Totals 0.00 0.00 0 0.00 0 0.00 0 0.00 0
200101 20010100 XXXXXXX Popular Store Loto 36,100.00 0.00 0 0.00 36 -5,646.00 0 0.00 0
200101 20010100 XXXXXXX Popular Store Inst Tk 22,000.00 0.00 0 0.00 166 -9,360.00 0 0.00 0.00
200101 20010100 XXXXXXX Popular Store Totals 58,100.00 0.00 0 0.00 202 -15,006.00 0 0.00 0
200103 20010300 XX XXXXXXXX Snack Loto 35,980.00 0.00 0 0.00 20 -3,426.00 0 0.00 0
200103 20010300 XX XXXXXXXX Snack Inst Tk 14,000.00 0.00 0 0.00 157 -9,180.00 0 0.00 0.00
200103 20010300 XX XXXXXXXX Snack Totals 49,980.00 0.00 0 0.00 177 -12,606.00 0 0.00 0
8 rows selected.
SQL>
Published by: BluShadow on January 22, 2010 13:37
added the retailer's name as well, but out anonymous that we dislike the actual data on the forums... ;)
Tags: Database
Similar Questions
-
How to read data from an Excel 2010 worksheet with the .xlsx extension? The data I want, it's on one of the 10 tabs in the file, I have to choose which programmatically. I have the Report Generation Toolkit for LV2012, but all the screws that come with it seem to focus around writing data to a spreadsheet Excel and make charts and whatnot. I want to * read * an Excel worksheet. Seeking answers led to many 'Open it and save it as tab delimited text', which I can't do because I need data from different tabs, and because this file is quite dynamic with many users opening and adding several times. In order to save the tab I want as a tab delimited text file per programming, I'm back a square, how to open it?
My solution would ideally fill in the blanks of: spreadsheet.xlsx---> _---> 2 or 3D data table.
Thank you
Adam
This fixes:
-
Read data from the file into ArrayList
Hello
I have a class called product describing the charactristics of products such as the name, id, price etc.. I have the whole set and use the get methods in my class of product. I store the information on my products in an ArrayList. I can write the information on my products in a file.
so far, but so good...
I want now to re-read the data from the file and store it in my list of tables again. I know I can use Parsing and read in data in an ArrayList as String, int, double etc. but is anyway to read in from 'Product' (then it would be up to my class of product)?
Thank you in advance.1. are you aware of serialization?
2. get a name, I love not dealing with numbers.DB
-
How to read data from several files and add columns in a single file
Hi guys,.
I have a problem in adding data from files in different columns. I have the attachment a file A and B which I am reading and not able to get the data in the Result.txt file. Please give your opinion on how can I do this
You must add the data of all files before proceeding with a single entry.
-
I would like to read data (sepereated of numbers with spaces) and write them in a table. That's what I have so far.
Thank you.
Try to use "worksheet reading File.vi. The only thing you will obviously need to change is the delimiter character, which seems to be a white. In the default configuration, spreadsheet files using the tabs as separators...
Norbert
-
Hi all
I have an xml file store on my bb.
How can I read data within the tag? I think that one way is to use blackberry.find.FilterExpression (), like the example below. I don't know how... but it's okay. I will try!!
function handleOpenedFile(fullPath, blobData) { temp = blackberry.utils.blobToString(blobData); //var NomeOperatore = blackberry.find.FilterExpression(''); } function readPianoViaggi() { if (blackberry.io.file.exists(filePath)) { blackberry.io.file.copy(filePath, filePath2); blackberry.io.file.readFile(filePath, handleOpenedFile); } }
my question is: I can read data within the tag using an operation such as
itemDescription = temp.getElementsByTagName ('NomeOperatore') var [0].firstChild.data or something similar?
Thank you
You would do something like the following... I don't know if my syntax is correct
function readFile() { blackberry.io.file.readFile("file:///store/home/user/sample.xml",handleOpenedFile); } function handleOpenedFile(fullPath, blobData) { var xmlString = blackberry.utils.blobToString(blobData, null); var parser = new DOMParser(); var doc = parser.parseFromString(xmlString, "text/xml"); var itemDescription = doc.getElementsByTagName('NomeOperatore')[0].firstChild.data; }
-
The values of cursor two corresponding and insertion into tables
I ' am using sql developer oracle 11g.
I have 3 tables called
PRODUCT_NOTIFICATION
RECORD
PCS_NOTIFICATION
--------------------
PRODUCT_NOTIFICATION
ID TITLE Message 21 sale 50% discount on all brand products RECORD
ID REGNAME ACTIVATIONCODESTATUS MOBILENUM 747407931107 TEST THERE 12345 39717371107 TESTuco1 THERE 6789 Now, I want to take only the message of product_notification table column and
pick up the registered customer of registration table where the activationcode_status = 'Y '.
PCS_NOTIFICATION
Output of desire in the PCS_NOTIFICATION TABLE
ID MOBILENUM Message 1 12345 50% discount on all brand products 2 6789 50% discount on all brand products THEN insert the message in pcs_notification.
It is the procedure goes as...
create or replace
PROCEDURE sp_notification)
p_out_msg OUT VARCHAR2
)
AS
CURSOR C_product_notification
IS
Select the description of product_notification;
-Search for registered customer
CURSOR C_registered
IS
Select * from registration where activation_code = 'Y ';
for k C_INSERT
LOOP
THEN
BEGIN
If C_product_notification = C_registered THEN
INSERT INTO PRODUCT_CLOUD_NOTIFICATION VALUES () - stuck here
---------------------
---------------------------------
--------------------------------------
Goal is to send the generic message for every individual mobile numbers of registered customers.
Help, please...
Create a sequence object to fill PCS_NOTIFICATION.ID. allows you to call him PCS_NOTIFICATION_ID_SEQ.
Now all you need is a simple insert statement.
insert into pcs_notification (id, mobilenum, message) select pcs_notification_id_seq.nextval, r.mobilenum, pn.message from product_notification pn cross join registration r where r.activationcodestatus = 'Y';
-
read data from utl file in xml format
I need like this...
UTL file (on server) I'll have 10 records in xml format, the file is located in the xml extension.
now I want to read all 10 records in the server using the UTL files
and I want to extract the values of labels.
links or solutions?Why utl?
Why not use bfilename?
sample-
Re: How to insert rows from an xml file in a table
Re: Tags XML in the top or bottom of case? -
Cannot read data from avi file
Hello
I wrote timestamp data and exposure to an AVI file, but I can't as the file data using the read avi function. I enclose the code to play the video, but also an excerpt of 7 video framework. If you open the video in a hex editor and search for 'Time', you can see that the data has been written to the file, but I just get the empty string when I try to read this return as in the attached VI. I'm doing something wrong?
I use LV 8.0.1 and IMAQ Vision 7.1.1 4.0.
Thank you
Greg
Thank you for your help.
Finally, I got this problem. I tried the IMAQ upgrade as you said, repair facilities IMAQ, LabView and removing and reinstalling all my software of NOR. None of this has helped.
In that time, I had a lot of other problems with NOR-MAX, got totally fed upwards, formatted the hard drive and reinstalled windows, LabView and all the stuff of vision. In the process, I discovered that I had bad RAM and replaced the one too.
Almost all problems are gone now, including this one.
Thank you
Greg
-
Hello
attempt to read a file of values, calculate the average arithmetic and printing results:
[JAVA] import java.io.FileNotFoundException;
import java.io.FileReader;
Import Java.util;
import java. IO;
public class MainClass
{
Public Shared Sub main (String [] args)
throws IOException
{
int sum = 0;
int count = 0;
End FileReader = new FileReader ("in.txt");
Scanner src = new Scanner (end);
Number of reading and the amount.
While (SRC.hasNext ())
{
If (SRC.hasNextInt ())
{
sum += src.nextInt ();
Count ++;
}
}
end. Close();
System.out.println ("Average is" + sum/count);
}
}
[JAVA]
File is as follows:
5 2
1.7-4 2
4.5 0 2
6.73 9 0.34
3 11,13 0.77
using Eclipse
I press run, but then nothing happens, but it is clear that what is responsible, but nothing is displayed.
Displays the error message: unable to connect to the virtual machine
com.sun.jdi.connect.TransportTimeoutException
What is the problem? What is the problem? Help, please
Edited by: 887785 the 27.09.2011 05:29887785 wrote:
Helloattempt to read a file of values, calculate the average arithmetic and printing results:
[JAVA] import java.io.FileNotFoundException;
import java.io.FileReader;
Import Java.util;
import java. IO;public class MainClass
{Public Shared Sub main (String [] args)
throws IOException
{
int sum = 0;
int count = 0;
End FileReader = new FileReader ("in.txt");
Scanner src = new Scanner (end);
Number of reading and the amount.
While (SRC.hasNext ())
{
If (SRC.hasNextInt ())
{
sum += src.nextInt ();
Count ++;
}
}
end. Close();
System.out.println ("Average is" + sum/count);}
}
[JAVA]File is as follows:
5 2
1.7-4 2
4.5 0 2
6.73 9 0.34
3 11,13 0.77using Eclipse
I press run, but then nothing happens, but it is clear that what is responsible, but nothing is displayed.
Displays the error message: unable to connect to the virtual machine
com.sun.jdi.connect.TransportTimeoutExceptionWhat is the problem? What is the problem? Help, please
Edited by: 887785 the 27.09.2011 05:29
What happens when you run this command line?
-
Can read data from xls using teststand 3.5?
Hello
I use 3.5 TestStand and LabVIEW 8.je know these are quite old versions now, but we must continue with this on a test bench.
My question is how can I read data from the file xls using TestStand 3.5? I have already mentioned a few posts on this, and one response suggested that I should use "tGetExcel" using ActiveX adapter. I tried to run the test example related to "http://forums.ni.com/t5/NI-TestStand/Write-or-read-to-Excel-from-TestStand/td-p/250439/highlight/tru...", but a run-time error. He says that "the tGetExcel type library information not found. Make sure that the server is registered in the system.
TestStand 4.2, I could easily run excel at the base of operations by using the Office Excel Toolkit.
I was wondering, is there another way, I can read just .xls file data by using Teststand 3.5?
Thank you
Niraj.
Please check this example for charger of property:
C:\Program Files (x 86) \National Instruments\TestStand 3.5\Examples\LoadingLimits
This shows the limits of excel file loading.
But you can load the values of the variables-consult the help file / Reference manual for this type of step.
Also in the loader type forum search property - you can find more information.
I hope this helps.
-
I need help (I have not the slightest idea) with a java script to program a button to retrieve an image from a user base and insert into a form field. To go to the menu select icon.
[edited by moderator - he had no body to the post office and it was while heading a long title.] [Shorten the title and pasted the original title, plenty of length as the message body]
Okay, that's actually quite easily. As the l' evenement event MouseUp button, select "Execute JavaScript" and enter this code:
event.target.buttonImportIcon ();
When you click the button it will open a file selection dialog and the selected file is displayed under the icon of the button.
-
Read data from table of $ E and insert in the staging table
Hi all
I'm new on ODI. I need your help to understand how to read data from a table ' E$ "and insert in an intermediate table.
Scenario:
The name of two columns, in a flat file, the employee and the employee id must be loaded into a data EMPstore +. A check constraint is added so that the data with the employee names in capital letters only to load in the data store. Check the command is set to the static movement . Right-click on the data store, select control , then check. The lines that have violated the check constraint are kept in E$ _EMP+ table.
Problem:
Problem is I want to read the data in the table E$ _EMP+ and transform in capital letters in the name of the employee and move the corrected data of E$ _EMP+ EMP+. Please advise me on how to automatically manage the 'soft' exceptions in ODI.
Thank youIf I understand, you want to change the columns in the tables of $ E and then load into the target.
Now, if you notice how ODI recycles the error, there is an incremental update to the target using the E table $ after he filled the I$ table.
I think you can do the same thing by creating an interface using the table of $ E as source and implement the business logic in this interface to fill the target.
-
How to read data from an excel and HTML file
Hello
I write a 2D-array of string in Excel/HTML file using the generation of reports.
Can someone tell me how to get back in return, the written data, same files again and display in table format.
Thank you & best regards
Visuman
You can use activex to read data from the excel fileback to the table format... through this vi... may b this will help you...
-
Reading data from a text (JS CS3) file tabs-delimited
Hi - I'm working on a script to read data from a text file and use in a dialog box. But I hit a wall.
I used a script from a previous post that defines a variable text document when the user script he chooses from a drop-down list.
var myDialog = app.dialogs.add({name:"Map",canCancel:true});)
{with (MyDialog)}{with (dialogColumns.Add ())}
{with (borderPanels.Add ())}
staticTexts.add ({staticLabel: "choose the location :"});})
{with (dialogColumns.Add ())}
var file = File("~/Desktop/myPlacesfile.txt");leader. Open ("r");
var str = file.read ();
leader. Close();
var myPlaceList = str.split (/ [\r\n] + /);
var myPlaceMenu = dropdowns.add ({stringList:myPlaceList, selectedIndex:0});})
}
}}}
Ditto var = myDialog.show ();
if(myResult == true) {}
If (myPlaceMenu.selectedIndex == 0) {}
myPlace var = ' - undefined ";
} else {}
myPlace var = myPlaceList [myPlaceMenu.selectedIndex];
Alert (myPlace);
}myDialog.destroy ();
}That's what I do now:
The text file is in this format:
Value1 value2 [TAB]
Value1 value2 [TAB]
Value1 value2 [TAB]
I need to have the drop down dialog box show only the value 1, and after that the user selects, the script returns only the value 2. (The alert is just there to test - I'm doing something else with the variable).
Is there a way to view the first part of a tab-delimited line in the menu drop down and return the second half as a variable?
Any help would be greatly appreciated.
Thank you
One of the possibilities is that it. Create a table to the left of the values of the tab of the dialog box. Then create an object that you use it as a table of correspondence. Roughly as follows:
same thing as what you have
leader. Open ("r");
var str = file.read ();
leader. Close();
var array = str.split (/ [\r\n] + /);'pairs' are the table of correspondence
pair of var = {};
as before, 'myPlaceList' will be used for the menu drop-down
var myPlaceList = [];var v;
for (var i = 0; i)< array.length;="">
{
v = table [i] .split ('\t');
pairs [v [0]] = v [1];
myPlaceList.push (v [0]);
}Add the drop-down list as before:
var myPlaceMenu = dropdowns.add ({stringList:myPlaceList, selectedIndex:0});})
the table of 'pairs' correspondence is used as follows: pairs ['value1'] returns 'value2 '.
so in your script that would be:
myPlace var pairs = [myPlaceList [myPlaceMenu.selectedIndex]];
Peter
Maybe you are looking for
-
Where the Netscape Public License Version 1.1?
Try to install Windows Media Player Firefox Plugin.The Microsoft license agreement says that it contains files that are subject to the Netscape Public License Version 1.1, and that the user is unable to use these files, except in compliance with the
-
Re: Webcam disabled on Satellite A350
I'm having a problem with my webcam on Toshiba Satellite A350, Win7 Professional 32-bit. The webcam no longer works. Camera software allow me to open camera - keeps saying "Webcam is either disabled or has failed.» Please check your webcam settings '
-
Is there a convenience store to fix my cd-rom?
Hi, my cd rom is not working. There the troubleshooting tools that I can use to fix this.regards Garry
-
ThinkPad Edge E425 SSD upgrade
Hi guys,. After 2 and a half years of satisfactory using this laptop, I decided to finally the 320 GB HD a 120 GB SSD in this little boy. I am aware that SSD connectors differ from normal laptop HD connectors. I want to know what follows- My laptop i
-
Cannot add a printer from the network
Hello, in our House, we have 3 laptops and 1 pc. The 3 laptops were able to print to the printer connected to the main computer. One of the laptop crashed and it should restore it. Once restored, we added to the Working Group and tried to add a print