Parsing a file with different groupings!
I need to parse a file. The file looks like this.
ABC45 CLIENT-90 MY COMPANY-0333 STOCK VS POSITIONS DATE
......n number of records here
ABC45 CLIENT-90 MY COMPANY-0897 STOCK VS POSITIONS DATE
.....n number of records here
ABC 45 CLIENT-90 MY COMPANY-0333 STOCK VS POSITIONS DATE
....n number of records here
ABC 45 CLIENT-90 MY COMPANY-0367 STOCK VS POSITIONS DATE
....n number of records hereI need to get all the records under say "MY COMPANY-0333" and parse them further and output to a text file. How can I do that?
Thanks
You have header and detail records, I suppose. Let's call them that. Pseudocode:boolean rightStuff = false;
for each record:
if it's a header record:
if it has MY COMPANY-0333 in the right place then rightStuff = true else rightStuff = false
if it's a detail record:
if rightStuff then process it and write to the filePC²
Similar Messages
-
Parsing XML file with different languages (Xerces)
How do we code or program to an XML file with different
languages , say english and spanish. WHen we parse such a document with the default locale , the presence of special characters throws errors .For eg when I use xerces and use
DOMParser parser = new DOMParser();
try
// Parse the XML Document
parser.parse(xmlFile);
catch (SAXException se)
se.printStackTrace();
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xfc) was found in the element content of the document.
System Error: void org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
So what locale do we set before we parse ?How to handle this problemYou need an encoding attribute in the xml declaration. If you don't, the parser assumes UTF-8, which are ASCII characters up to 127 - useful (only) for English.
So, something like this would allow you to use characters above 127, ISO-8859-1 is the encoding used by standard PCs.
<?xml version="1.0" encoding="ISO-8859-1"?>
You can find a (offical) list of encodings at:
http://www.iana.org/assignments/character-sets
I'm not sure about mixing various encodings. I think you have to resort external parsed entities, which can have their own encoding, but I think you cannot mix encodings in one XML file.
Good luck. -
SSIS project - read multiple flat files with different formats
hi all,
i need to import multiple flat files with different formats into different tables of the sql server database and not able to figure out the best way out in ssis to do so...
please advise the possible methods in ssis to do so and if possible the process which can be dynamic as file names or columns might change in future.Hi AK1987,
To import flat files with dynamic columns, we can use Script Task inside a Foreach Loop Container to parse the first row of the flat file to get the columns names and save them into a .NET variable, then, we can create “Create Table” script based on this
variable, and then store the script into a SSIS package variable. After that, we create a staging table based on the package variable, load the flat file data to the staging table. Eventually, we load data from the staging table to the destination table. For
the detail steps, please walk through the following blog:
http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/
Regards,
Mike Yin
TechNet Community Support -
How can i compare two excel files with different no. of records.
Hi
I am on to a small project that involves us to compare two excel files. i am able to do it but am struck up at a point. When i compare 2 different .csv files with different no. of lines i am only able to compare upto a point till when the number of lines is same in both the files.
Eg. if source file has 8 lines and target file has 12 lines. The difference is displayed only till 8 lines and the remaining 4 lines in source lines are not shown.
Can you help me in displaying those extra 4 lines in source file. I am attaching my code snippet below..
while (((strLine = br.readLine()) != null) && ((strLine1 = br1.readLine())) != null)
String delims = "[;,\t,,,|]";
String[] tokens = strLine.split(delims);
String[] tokens1 = strLine1.split(delims);
if (tokens.length > tokens1.length)
for (int i = 0; i < tokens.length; i++) {
try {
if (!tokens.equals(tokens1[i])) {
System.out.println(tokens[i] + "<----->" + tokens1[i]);
out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + tokens1[i]);
out.println();
sno++;
} catch (Exception exception)
out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + "");
out.println();
Thanks & RegardsA CSV file is not an Excel file.
But apart from that your logic makes no sense.
If the 2 files are of different sizes the files are different by definition, so further comparison isn't needed, you're done.
If you want to compare individual records, you need to compare all records from one file with all records from the other, unless the order of records is important in which case your current system might work.
That system however is overly complicated for comparing CSV files.
As you assume a single record per line, and if one can assume those records to have identical layout (so no leading or trailing whitespace in or between columns in one file that's not in the other) comparing records is simply a matter of comparing the entire lines. -
From sap to excel file with different sheets?
can i upload an internal table from SAP to single Excel file with different sheets for example like : sheet1, sheet2, sheet3.......sheet10. , but need to upload data from sap to excel worksheets ie. from multiple named tabs in Excel. Is this possible, and if so, please can you help and advise me how?
thanks
venkat.
Edited by: Matt on Feb 16, 2009 2:15 PM Removed excessive question marks...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Hi venkat,
Yes indeed it is possible to write data from internal table to different excel sheets. Check out SAP's Microsoft OLE functionality.Search on SDN for OLE . Following are some links
https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/sample%252bprogram%252bto%252bopen%252bexcel%252bsheet%252busing%252bole
You can also check out FM ALSM_EXCEL_TO_INTERNAL_TABLE to check how to read different worksheets.
Using the above two resources you can create a program that can upload data to multiple worksheets in the same workbook.
Also see this link
Creating Excel with More than one page
Edited by: aditya aghor on Feb 16, 2009 1:57 PM
Edited by: aditya aghor on Feb 16, 2009 2:02 PM -
Reading fixed length file with different record types
Hi,
I need to read a fixed-length file with different record types, but the record identifier is in 31st position and not in 1st position.
But if I give 31 as position in File adpater wizard, BPEL takes whole 1-31 as identifier.
How we need to read such files.
Thanks
Ravdeephi ,
u cannot use the default wzard for this
use some thing like this nxsd:lookAhead="30" nxsd:lookFor="S"have a look at the below link it has some examples
http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm -
How to generate a second csv file with different report columns selected?
Hi. Everybody:
How to generate a second csv file with different report columns selected?
The first csv file is easy (report attributes -> report export -> enable CSV output Yes). However, our users demand 2 csv files with different report columns selected to meet their different needs.
(The users don't want to have one csv file with all report columns included. They just want to get whatever they need directly, no extra columns)
Thank you for any help!
MZHello,
I'm doing it usually. Typically example would be in the report only the column "FIRST_NAME" and "LAST_NAME" displayed whereas
in the csv exported with the UTL_FILE the complete address (street, housenumber, additions, zip, town, state ... ) is written, these things are needed e.g. the form letters.
You do not need another page, just an additional button named e.g. "export_to_csv" on your report page.
The csv export itself is handled from a plsql procedure "stored procedure" ( I like to have business logic outside of apex) which is invoked by pressing the button "export_to_csv". Of course the stored procedure can handle also parameters
An example code would be something like
PROCEDURE srn_brief_mitglieder (
p_start_mg_nr IN NUMBER,
p_ende_mg_nr IN NUMBER
AS
export_file UTL_FILE.FILE_TYPE;
l_line VARCHAR2(20000);
l_lfd NUMBER;
l_dateiname VARCHAR2(100);
l_datum VARCHAR2(20);
l_hilfe VARCHAR2(20);
CURSOR c1 IS
SELECT
MG_NR
,TO_CHAR(MG_BEITRITT,'dd.mm.yyyy') AS MG_BEITRITT ,TO_CHAR(MG_AUFNAHME,'dd.mm.yyyy') AS MG_AUFNAHME
,MG_ANREDE ,MG_TITEL ,MG_NACHNAME ,MG_VORNAME
,MG_STRASSE ,MG_HNR ,MG_ZUSATZ ,MG_PLZ ,MG_ORT
FROM MITGLIEDER
WHERE MG_NR >= p_start_mg_nr
AND MG_NR <= p_ende_mg_nr
--WHERE ROWNUM < 10
ORDER BY MG_NR;
BEGIN
SELECT TO_CHAR(SYSDATE, 'yyyy_mm_dd' ) INTO l_datum FROM DUAL;
SELECT TO_CHAR(SYSDATE, 'hh24miss' ) INTO l_hilfe FROM DUAL;
l_datum := l_datum||'_'||l_hilfe;
--DBMS_OUTPUT.PUT_LINE ( l_datum);
l_dateiname := 'SRNBRIEF_MITGLIEDER_'||l_datum||'.CSV';
--DBMS_OUTPUT.PUT_LINE ( l_dateiname);
export_file := UTL_FILE.FOPEN('EXPORTDIR', l_dateiname, 'W');
l_line := '';
--HEADER
l_line := '"NR"|"BEITRITT"|"AUFNAHME"|"ANREDE"|"TITEL"|"NACHNAME"|"VORNAME"';
l_line := l_line||'|"STRASSE"|"HNR"|"ZUSATZ"|"PLZ"|"ORT"';
UTL_FILE.PUT_LINE(export_file, l_line);
FOR rec IN c1
LOOP
l_line := '"'||rec.MG_NR||'"';
l_line := l_line||'|"'||rec.MG_BEITRITT||'"|"' ||rec.MG_AUFNAHME||'"';
l_line := l_line||'|"'||rec.MG_ANREDE||'"|"'||rec.MG_TITEL||'"|"'||rec.MG_NACHNAME||'"|"'||rec.MG_VORNAME||'"';
l_line := l_line||'|"'||rec.MG_STRASSE||'"|"'||rec.MG_HNR||'"|"'||rec.MG_ZUSATZ||'"|"'||rec.MG_PLZ||'"|"'||rec.MG_ORT||'"';
-- DBMS_OUTPUT.PUT_LINE (l_line);
-- in datei schreiben
UTL_FILE.PUT_LINE(export_file, l_line);
END LOOP;
UTL_FILE.FCLOSE(export_file);
END srn_brief_mitglieder;Edited by: wucis on Nov 6, 2011 9:09 AM -
Creating pdf-file from multiple files with different orientation
How do I put together two files with different orientation in the page set up so that the lying A4-format is standing up in the new pdf-file?
lophelia wrote:
How do I put together two files with different orientation in the page set up so that the lying A4-format is standing up in the new pdf-file?
First I've underline a Phrase in your Question did you mean underlying A4-format?
Are both PDF Files created with A4-Format? If yes then:
Did you shift orientation to Portriat Format for the item(s) that you need, such as a Chart or an excel Document? If so:
Then when the documents are meged They should print correctly. -
SSIS - Import Multiple flat files with different metadata
Hi ,
I have set of flat files with different metadata structure, I would like to load them into staging tables.
1. ) Can we load the flatfiles into the staging tables with out having multiple data flow task.
2.) If possible , can we programmatically select the staging table based on the metadata of the flatfile and load them.
Please advise.
Thanks
ThiyaNope in SSIS a data flow task needs to have a fixed metadata. So if your file metadata varies then best option would be use OPENROWSET syntax to pull the data and populate into your staging table. You may also use
SELECT .. INTO StagingTable ... FROM OPENROWSET (...)
syntax to create staging table at runtime based on the file metadata
http://sqlmate.wordpress.com/2012/08/09/use-your-text-csv-files-in-your-queries-via-openrowset/
If you want to do this in SSIS you need to create data flow dynamically using script task and build the metadata
see
http://www.selectsifiso.net/?p=288
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Printing different/selective files with different copies
Hi everyone,
I've been working on finding a solution, on how to print different pdf files with different copies, without opening the pdf-files.
Task:
I have a folder, with 25 pdf files
I want to make a php overview, of the folder
At the end of each line/file - i would like to add a number for the copies
In the end, I would like to simply press print - and every document ive added a number/copies to - are being printet...
I guess I need to use PrintPDF - but does anyone know any pre-made program/function - that could handle the "copies" part...?
I hope someone can help me out,
Thanks
JanWell, i had hoped that the acrobat could open silent - eventhough they've removed that feature in the newer versions.
Even though the program would open - if the amount of copies was added - and i just hat to press print - it would ease the job alot. -
XML file with different format
Hello
I have a requirement where the customer needs XML file with different format. How do I achieve the second format mentioned below instead of first format.
Normally we create the XML file in the following format:
- <Entries>
- <Organization>
<MemberName>0000000002</MemberName>
<FullName>BAY GYNECOLOGICAL ASSOCIATES</FullName>
<OrgId>0000000002</OrgId>
<OrgType>CUST</OrgType>
- <AssociatedToOrg>
<Name>0002</Name>
- </AssociatedToOrg>
</Organization>
Now the customer wants like the following format:
<Organization MemberName="522_Community_Customer" FullName="522 Community Customer" OrgId="DEA123456" OrgIdType="DEA" >
<AssociatedToOrg Name="MN"/>
</Organization>
Thanks
Nagayou can solve it with a XSL mapping. refer to the SDN to know how develop it
/people/aleksey.popov2/blog/2010/01/26/consuming-webservices-with-tag-in-wsdl-using-xslt
XSLT Editor for creating xlst mappings
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/190eb190-0201-0010-0ab3-e69f70b6c257
http://wiki.sdn.sap.com/wiki/display/XI/XSLTMappingSteps
http://wiki.sdn.sap.com/wiki/display/XI/FileTOFile-UsingXSLTmapping%28forBeginners%29
http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertflatXMLfiletonestedusing+XSLT
http://wiki.sdn.sap.com/wiki/display/Java/MultiMappingwithJavaandXSLTmappings
Edited by: Rodrigo Alejandro Pertierra on Oct 1, 2010 5:26 PM -
Streaming files with different folders
Hi
i am new to FMS4 and i am having a problem playing some files with different folders.
i have different folders in C:\media3\feeds
in that directory i have folder "1", "2" and "3"
other words C:\media3\feeds\1
C:\media3\feeds\2
C:\media3\feeds\3
in config folder i changed fms.ini
VOD_DIR = C:\media3\feeds\
and
VOD_COMMON_DIR = C:\media3\feeds\
i only got the f4v files to work in C:\media3\feeds\ which link is rtmp://localhost/vod/mp4:testfile.f4v
so i tired to have some folders in C:\media3\feeds\ like mention above
i tried to put <Streams>/;<C:\media3\feeds\1</Streams> in Applications.xml file in the C:\Program Files\Adobe\Flash Media Server 4\applications\vod
and used rtmp://localhost/vod/1/mp4:testfile.f4v
here is piece of the App file
<Application>
<StreamManager>
<VirtualDirectory>
<!-- Specifies application specific virtual directory mapping for recorded streams. -->
<Streams>/;${VOD_COMMON_DIR}</Streams>
<Streams>/;${VOD_DIR}</Streams>
<Streams>/;<C:\media3\feeds\1</Streams>
<Streams>/;<C:\media3\feeds\2</Streams>
</VirtualDirectory>
nothing worked
can some one help me with this??If you are using
VOD_DIR = C:\media3\feeds\ or VOD_COMMON_DIR = C:\media3\feeds\
and having files in folder "1" which is under "C:\media3\feeds\"
then you URI should be rtmp://localhost/vod/mp4:1/testfile.f4v (where testfile.f4v is present under C:\media3\feeds\1)
If you are using
<Streams>/;C:\media3\feeds\1</Streams>
<Streams>/;C:\media3\feeds\2</Streams>
Then your URI should be rtmp://localhost/vod/mp4:testfile.f4v (where testfile.f4v is present under C:\media3\feeds\1 or C:\media3\feeds\2)
Also please note in your configuration which you have specified
<Streams>/;<C:\media3\feeds\1</Streams><Streams>/;<C:\media3\feeds\2</Streams>
please remove "<" in "<C:\media3\feeds\1" and "<C:\media3\feeds\2" -
Parse exisitng xml file and recreate another xml file with different struct
Is it possible in java using dom parser to parse an exisiting xml file and recreate a new xml file from data obtained by parsing old xml file.
I checked on old forum threads and everywhere either parsing xml file has been explained or creating new xml file from scratch has been shown.
Any examples/guidance will be appreciated....The general process is:
Document dom1 = ... // the parsed document
Document dom2 = ... // new document constructed on the fly
Node nD1 = ... // some random node found in dom1
// copy the node from dom1 and associate with dom2
Node nD2 = dom2.importNode(nD1, true);
// ... treat nD2 as a node which can now be inserted into dom2 ...
Node otherD2 = ... // some other node already in dom2
otherD2.appendChild(nD2);Note, in this example the nD1 node is copied (including any sub-nodes) into a new node, nD2. You can alternately move the node from one Document to another using Document.adoptNode(), however this may fail (see the javadoc). -
Using ssis import a multiple flat files with different mappings
I have an scenario for import a file
20 different flat file source and having XML mapping document in a table.
get files from that path(i have path and file name extension in table)
i have map this file based on the file name extension in dynamically
create a 20 different staging table based on mapping in dynamically
kindly help for this
Hi Karthick,
As Arthur said, if you don't want to hard code the data flow, you need to read XML from the SQL Server table and use Script Task to implement the dynamic columns mapping. To read XML from a SQL table, you can refer to:
http://blog.sqlauthority.com/2009/02/13/sql-server-simple-example-of-reading-xml-file-using-t-sql/
In the Script Task, we need to parse the first row of the flat file to get the columns information and save that to a .NET variable. Then, the variable will be used to create the query that will be used to create SQL table. For more information, please see:
http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/
Regards,
Mike Yin
TechNet Community Support -
Too many flat files with different formats.
Hi gurus,
i have a headache problems. that is follows:
We will upload data from flat files,but you know there are about 100 .xls files and with different formats.
and as you know the datasource of the flat file must correspond to every fields of the flat file.
but you know there are 100 flat files and if we donot do any optimise,we will create about 100 transformation and 100 datasource to meet our requirements.
but that seems impossible.
is there any good idea to decrease the number of transfomation ?Hi AK1987,
To import flat files with dynamic columns, we can use Script Task inside a Foreach Loop Container to parse the first row of the flat file to get the columns names and save them into a .NET variable, then, we can create “Create Table” script based on this
variable, and then store the script into a SSIS package variable. After that, we create a staging table based on the package variable, load the flat file data to the staging table. Eventually, we load data from the staging table to the destination table. For
the detail steps, please walk through the following blog:
http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/
Regards,
Mike Yin
TechNet Community Support
Maybe you are looking for
-
Application is not displaying correctly and is showing as incomplete
please i really need help i am not understanding this at all i need to send them as pdf files because there application forms I have an issue when it comes to sending the pdf files to someone else and they open the file to then tell me that the text
-
Can someone please tell be if this TV is Bluetooth capable and if so what the pair code is?
-
Customizing oralce reports for 11i
Where can I find documents regarding the procedures of modifying oralce apps reports? I want to know specifically how to register a customized reports in 11i. thanks! - Server name - Filename - Date/Time - Browser + Version - O/S + Version - Error Ms
-
I recently reset my Iphone 4S 16 GB and I backed it up with Icloud. I got everything back ( apps, music, photos, ETC.) accept for my purchased ringtones. I am trying everything to get them back. I know they are still there because when I tried to pur
-
Can't find Classic support on Tiger DVD
I need help. I recently purchased a used 17" powerbook. I wiped out the hard drive and installed the Tiger DVD, and everything works fine... but I can't find anything that installs Classic. Can I install the Classic Environment from the Tiger DVD? Or