Convert tab delimited file content into an xml
Hi,
I am completely new to java and i am trying to create a tree of an
output i have. generally the output is tab delimited and i have a
sample output in the following link
http://jena.sourceforge.net/ontology/examples/class-hierarchy/output.txt
I want to create an xml out of it in the tree format as below
<Class :Thing>
(/t) <Class :KoalaWithPhD>
(/t) <Class :MaleStudentWith3Daughters>
(/t) <Class :Habitat>
</Class :Thing>
note i have added (/t ) just to explain u that kolawithphd is child node of thing ...and so on.
Can someone throw in a simple code snipet that can help me do this.
Really appreciate your help
Thanks
aks
You need to detect the amount of indent, and whether the current line is more or less indented. You also need a stack to hold the indents of the previous lines, so the converter knows which one it's matching.
Assuming the output is like the jena example - spaces only as indent and no non-xml-attribute-value characters in the class names, one possible converter would look like:import java.io.*;
import java.util.*;
public class ClassesToXml {
public static void main (String[] args) {
try {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(args[0]));
String line;
int previousIndent = -1;
LinkedList stack = new LinkedList();
System.out.print("<classes");
while ((line = in.readLine()) != null) {
final int indent = indent(line);
if (indent <= previousIndent) {
System.out.println("/>");
while (indent < previousIndent) {
System.out.println("</class>");
previousIndent = ((Integer)stack.getFirst()).intValue();
stack.removeFirst();
} else {
System.out.println(">");
stack.addFirst(new Integer(previousIndent));
previousIndent = indent;
System.out.print("<class name='" +
line.substring(line.indexOf("Class ") + 6).trim() +
System.out.println("/>");
while (stack.size() > 1) {
System.out.println("</class>");
stack.removeFirst();
System.out.println("</classes>");
} finally {
if (in != null) {
in.close();
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
static int indent (String line) {
final int length = line.length();
for (int indent = 0; indent < length; indent++) {
if (line.charAt(indent) != ' ') {
return indent;
return length;
}Pete
Similar Messages
-
How to convert Mail attachment file Tab Delimited file to XML.
Hi PI Experts
I have XI scenario: MAIL XI SAP (ABAP Proxy), the process is
1. XI will receive tab delimited file as attachment in mail.
2. XI will convert the tab delimited file into XML, then map to the target structure.
3. Target will be posted into ECC through ABAP Proxy.
Can anyone help me how can I convert the attachment file (i.e. Tab delimited file) to XML while configuring the sender side.
Thanks in AdvanceI just grabed what I answered from another thread. It should work.
Processing sequence as follows:
1. localejbs/AF_Modules/PayloadSwapBean Local Enterprise Bean swap1
2. localejbs/AF_Modules/MessageTransformBean Local Enterprise Bean tran1
3. sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
Module Configuration as follows: Fill the XXXX part with your info.
swap1 swap.keyName payload-name
swap1 swap.keyValue MailAttachment-1
tran1 Transform.Class com.sap.aii.messaging.adapter.Conversion
tran1 Transform.ContentType ext/xml;charset=utf-8
tran1 xml.conversionType SimplePlain2XML
tran1 xml.documentName XXXXXXX_Mail
tran1 xml.documentNamespace http://XXXXX.com.au/XXXX
tran1 xml.fieldSeparator \t
tran1 xml.processFieldNames fromConfiguration
tran1 xml.structureTitle rows
Once you set up the above configuration, you will get one record at a time.
Create a souce message interface like the followings:
XXXXXXXXX_Mail
rows
record
Target message interface:
XXXXXXXXX
rows
field 1
field 2
field 3
Write a UDF function to remove the TAB space
public removeTABSpace(String record,Container container){
//write your code here
StringTokenizer st = new StringTokenizer(record,"\t",false);
String t="";
while (st.hasMoreElements()) t += st.nextElement();
return t;
Write another UDF to get the field 1 for example:
public String getField1(String input,Container container){
int counter=0;
int beginIndex=0;
int endIndex=0;
int i;
for (i=0;i<input.length();i++){
if (input.charAt(i)==34){
counter=counter+1;
if (counter==1){
beginIndex=i+1;
counter=0;
break;
for (i=0;i<input.length();i++){
if (input.charAt(i)==34){
counter=counter+1;
if (counter==2){
endIndex=i;
counter=0;
break;
input=input.substring(beginIndex,endIndex);
return input;
Get the mapping like the followings:
record - removeTABSpace - getField1 - field 1
If you need to get field 2, you will need to write another UDF similar to the above one to handle it. -
Import text into a form from a tab delimited file using an action
Good evening.
I am using Adobe Acrobat XI Pro
I have been working all weekend so far on this, and have tried many options.
What I am wanting is to import a line of data from an excel file into a form, save the file with a name drived from the form fields, close the new file, then go back to the original file, import a line of data, and so on and so on.
I had all of this working in livecyle with a tool, but now that we are going to Windows 8 and Microsoft Office 2013, the driver that I need to load the excel file into the form is not available--so now I have to redo the forms in Adobe and import using a tab delimited file.
I would like to do this with an action.
Thus far, I have the following.
**Credit goes to George Johnson who helped me with the script to save the file using field names a few months ago**
To start, I have a folder level script
mySaveAs = app.trustPropagatorFunction(function(doc,path)
app.beginPriv();
var myDoc = event.target;
myDoc.saveAs(path);
app.endPriv();
myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path)
//privileged and/or non-privileged code above
app.beginPriv();
mySaveAs(doc, path);
app.endPriv
//Privileged and/or non-privileged code below
For the Action, I start with the Form file loaded
Then I execute a javascript to import the text into the file.
this.importTextData("/c/data/clerical.txt");
The next step is to save the file using field names as part of the file name
--credit goes to George Johnson who assisted me with this on a similar project a few months ago.
//Get the Field Value
var fn=getField("Last").valueAsString + "-" + getField("First").valueAsString;
//Specify the folder
var fldr = "/c/data/";
//Determine the full path
var fp=fldr + fn + ".pdf";
//save the file
myTrustedSpecialTaskFunc(this, fp);
That is as far as I have gotten.
What I want to do now is load the original form file, import the next line into the form, save the file, repeat.
If anyone could assist me, I would greatly appreciate it.
**note I had to type this from my I-pad because I kept getting kicked off the internet from my computer. I hope my code is typed correctly.George
Thank you so much for your response.
Yes--there are multiple lines in the data file--it will vary from month to month. It looks like from what you are saying is that I need to do the global variable since it will constantly change, and then increment it as it goes through the text file. When it reaches the end, then it will stop.
I looked at the following links--but this is from Adobe 9 API--I don't know if things have changed with XI--especially since 9 used batch processing and XI has actions.
Count PDF Files
http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/ wwhelp.htm?href=JS_API_AcroJS.88.1.html
Global counter
http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/ wwhelp.htm?href=JS_API_AcroJS.88.1.html
I am not exactly sure how to include this in my code.
If you could point me in the right direction, I would appreciate it. -
Import tab delimited file into pdfs
I have a tab delimited file with 1000's of rows. I want to complete a form and save it for each row. Rather than using the importData() function by itself and manually going through each record I would like to automate this so it will fill out a form for each row and save a copy of each. I have a little experience in acrobat javascript, but some knowledge of building the form and adding javascript.
You can use the doc.importTextData method to import a row of data into the form and then use the doc.extractPages method to save to a new file, clear the form, and repeat the process for each row.
importTextData: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.502.html
extractPages: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.465.html
Note that the return codes for importTextData in the documentation are wrong. The positive values should be negative and vice versa. -
Trouble importing contacts from a tab-delimited file into Contacts on 10.9.5
I am having Trouble importing contacts from a tab-delimited file into Contacts on MacBook Pro, OS 10.9.5, Intel 2.4 GHz Core 2 Duo., 400GB drive, 4GB memory DDR3
So far I have:
- Followed closely the help screen in Contacts app
- Modified my source document meticulously - first in MS Word, then copied and tweaked in Apple's "Text Edit" app
- The problem arises when I go to access the document for import. Specifically, the target document, and all others in that file, are "greyed out" and thus can't be "opened" to facilitate the import process
- Tried changing the extension of the document name to ".txt", ".rtf", and ".rtd". No change or improvement.
- Searched Apple.com/help and found nothing relevant
Can anyone offer some advice or tell me what I may be overlooking in this process?
Any help will be greatly appreciated!
Thanks,
<Email Edited By Host>Hi Rammohan,
Thanks for the effort!
But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields. I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
Moreover I have about 10 such work areas. so the effort would be ten times the above effort! I want to avoid this! Please help!
I would be very grateful if you could provide an alternative solution.
Thanks once again,
Best Regards,
Vinod.V -
How to insert External XML file content into XMLTYPE through Pro*c
Could any one sugest me how to insert a external XML file content into Db
into XMLTYPE datatype through Pro*c program.
Thanks for any help...... who has done this
Ghanta TagoreHi
After some good fight of 3 days, I have done it through Pro*c
This is the way to handle this
Buffer-->Temporary Clob-->XMLTYPE(using CreateXml)
Pasting my piece o code to do this
===============
OCIClobLocator *license_txt;
varchar h_ttt[1024] = {'\0'};
ub4 amt;
int i;
EXEC SQL ALLOCATE :license_txt;
EXEC SQL LOB CREATE TEMPORARY :license_txt ;
GetName(name); /*Gets Name to insert into name column in License Table*/
for(i=0; i<4;i++)
GetXMLL((char *)h_ttt.arr); /*Gets a string value of XML into this example*/
/*<Tagore>Is From TCS Delhi</Tagore>*/
/*This can be changed to get buffer from FILE */
h_ttt.len = strlen((char *)h_ttt.arr);
amt = sizeof(char) * h_ttt.len ;
EXEC SQL LOB WRITE APPEND :amt FROM :h_ttt INTO :license_txt;
EXEC SQL
INSERT INTO license_table VALUES (:sss, :name, sys.xmltype.createXML(:license_txt))
================
Thanks For ur Help
Tagore Ghanta -
Read Tab delimited File from Application server
Hi Experts,
I am facing problem while reading file from Application server.
File in Application server is stored as follows, The below file is a tab delimited file.
##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
i have downloaded this file from Application server using Transaction CG3Y. the Downloaded file is a tab delimited file and i could not see "#' in the file,
The code is as Below.
c_split TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab.
here i am using IGNORING CONVERSION ERRORS in order to avoid Conversion Error Short Dump.
OPEN DATASET wa_filename-file FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
IF sy-subrc = 0.
WRITE : /,'...Processing file - ', wa_filename-file.
DO.
Read the contents of file
READ DATASET wa_filename-file INTO wa_file-data.
IF sy-subrc = 0.
SPLIT wa_file-data AT c_split INTO wa_adrc_2-kunnr
wa_adrc_2-title
wa_adrc_2-name1
wa_adrc_2-name2
wa_adrc_2-name3
wa_adrc_2-name4
wa_adrc_2-name_co
wa_adrc_2-city1
wa_adrc_2-city2
wa_adrc_2-regiogroup
wa_adrc_2-post_code1
wa_adrc_2-post_code2
wa_adrc_2-po_box
wa_adrc_2-po_box_loc
wa_adrc_2-transpzone
wa_adrc_2-street
wa_adrc_2-house_num1
wa_adrc_2-house_num2
wa_adrc_2-str_suppl1
wa_adrc_2-str_suppl2
wa_adrc_2-country
wa_adrc_2-langu
wa_adrc_2-region
wa_adrc_2-sort1
wa_adrc_2-sort2
wa_adrc_2-deflt_comm
wa_adrc_2-tel_number
wa_adrc_2-tel_extens
wa_adrc_2-fax_number
wa_adrc_2-fax_extens
wa_adrc_2-taxjurcode.
WA_FILE-DATA is having below values
##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
And this is split by tab delimited and moved to other variables as shown above.
Please guide me how to read the contents without "#' from the file.
I have tried all possible ways and unable to get solution.
Thanks,
ShrikanthHi ,
In ECC 6 if all the unicode patches are applied then UTF 16 will defintly work..
More over i would suggest you to ist replace # with some other * or , and then try to see in debugging if any further # appears..
and no # appears then try to split now.
if even now the # appears after replace statement then try to find out what exactly is it... wheather it is a horizantal tab etc....
and then again try to replace it and then split..
Please follow the process untill all the # are replaced...
This should work for you..
Let me know if you further face any issue...
Regards
Satish Boguda -
Handling Tab Delimited File generation in non-unicode for multi byte lang
Hi,
Requirement:
We are generating a Tab Delimited File in different languages (Single Byte and Multi Byte) and placing the files at application server.
Problem:
Our system is a Non-unicode system so we are facing problems with generation of Tab delimited file for multibyte languages like Russian, Japanese, Chinese etc.,
I am actually using data: d_tab TYPE X value '09' but it dont work for multi byte. I cant see tab delimited file at application server path.
Any thoughts about how to proceed on this issue?Please let me know.
Thanks & Regards,
Pavan>
Pavan Ravikanti wrote:
> Thanks for your answer but do you reckon cl_abap_char_utilities will be a work around for data: d_tab type X VALUE '09' .
> Pavan.
On a non-unicode system the X Variant is working, but not on a unicode system. Here you must use the class. On the other hand you can use the class on a non-unicode system und your char var will always be correct (one byte/twobyte depending on which system your report is running).
What you are planning to do is to put a file with an amount of possible characters into a system with has a less amount of characters. Thats not working in no way.
What you can do is to build up a multi-code-page system where the codepage is bound to the user or bound to the logon-language. Here you you can read and process textfiles in several codepages - but not a textfile in unicode. You have to convert the unioce textfile into a non-unicode textfile before processing it.
Remember that SAP does not support multi-code-page Systems anymore and multi-code-page systems will result in much more work when converting the system to unicode.
Even non-unicode system will not be maintained by SAP in the near future.
What you encounter here are problems for what unicode was developped. A unicode system can handle non-unicode textfiles, but the other way round will always lead to problems which cant be solved. -
Tab delimited file, to populate JTable
Hey all
As Java is fairly new for me I have come into several problems.
First of all i have a program making a tab delimited file, for example like this:
Mig 12345 You
Gig 12345 DouNow i want to read the file and populate each line in the JTable.
But my problem is the transfer from file to object.. This is my code so far:
String[] kolonneNavne = {"Kursusnavn",
"Kursusnummer",
"Point",
"Skemaplacering",
"Liniefag",
"Kursus taget"};
Object[][] kdata ={{null,null,null,null,null,null}};
try {
BufferedReader buff = new BufferedReader(new FileReader("kurser.ini"));
String linie = buff.readLine();
StringTokenizer t = new StringTokenizer(linie, "\t", false);
String kursus[] = {null,null,null,null,null};
int antalKurser = 0;
while (linie != null){
kursus[0] = t.nextToken();
kursus[1] = t.nextToken();
kursus[2] = t.nextToken();
kursus[3] = t.nextToken();
kursus[4] = t.nextToken();
kdata[0][antalKurser] = kursus[0];
kdata[1][antalKurser] = kursus[1];
kdata[2][antalKurser] = kursus[2];
kdata[3][antalKurser] = kursus[3];
kdata[4][antalKurser] = kursus[4];
kdata[5][antalKurser] = new Boolean(false);
linie = buff.readLine();
antalKurser++;
catch (ArrayIndexOutOfBoundsException e){
catch (IOException e){
e.printStackTrace();
}This should read every line in the file, and add the contents to kdata but it doesn't.
I've tried several things, reading the "How to Use tables" by java, and also looking at the Class "Scanner", but havn't got that working either.
I think that the error is in the assigning kursus[j] and kdata[][], but how do i do it? How kan i add contents to an array already having information:
Object[][] kdata;?
Is there a smarter way?
Afterwards i do the essential:
final JTable table = new JTable(kdata, kolonneNavne);Thanks for the debugging thing, i actually didn't know what it did..
Well if i change the assigning from the file with split, it should look like this:
try {
// For at l�se en linie af gangen
BufferedReader buff = new BufferedReader(new FileReader("kurser.ini"));
String linie = buff.readLine();
//Scanner sc = new Scanner(linie);
StringTokenizer t = new StringTokenizer(linie, "\t", false);
String kursus[] = {null,null,null,null,null};
int antalKurser = 0;
while (linie != null){
kdata[antalKurser] = linie.split("\t",5); // Or should this be kdata[0][antalKurser] ???
kdata[5][antalKurser] = new Boolean(false);
linie = buff.readLine();
antalKurser++;
catch (IOException e){
e.printStackTrace();
}But i still get errors when running the code...
Do i assign the data correct? It seems to me that that is the problem... I have tried searching for "object assign data java" but, all that comes up is "Object oriented programming with java"... Which i s understandeble beacause of java being Object oriented...
Hmm.. Hope you could help me with assigning the data!
It comes with this error:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5
at KursusTabel.<init>(KursusTabel.java:51)
at KursusTabel.createAndShowGUI(KursusTabel.java:103)
at KursusTabel.access$100(KursusTabel.java:15)
at KursusTabel$2.run(KursusTabel.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)Is it the first error that processes every other error? Thanks! -
Upload tab-delimited file from the application server to an internal table
Hello SAPients.
I'm using OPEN DATASET..., READ DATASET..., CLOSE DATASET to upload a file from the application server (SunOS). I'm working with SAP 4.6C. I'm trying to upload a tab-delimited file to an internal table but when I try load it the fields are not correctly separated, in fact, they are all misplaced and the table shows '#' where supposedly there was a tab.
I tried to SPLIT the line using as separator a variable with reference to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB but for some reason that class doesn't exist in my system.
Do you know what I'm doing wrong? or Do you know a better method to upload a tab-delimited file into an internal table?
Thank you in advance for your help.Try:
REPORT ztest MESSAGE-ID 00.
PARAMETER: p_file LIKE rlgrap-filename OBLIGATORY.
DATA: BEGIN OF data_tab OCCURS 0,
data(4096),
END OF data_tab.
DATA: BEGIN OF vendor_file_x OCCURS 0.
* LFA1 Data
DATA: mandt LIKE bgr00-mandt,
lifnr LIKE blf00-lifnr,
anred LIKE blfa1-anred,
bahns LIKE blfa1-bahns,
bbbnr LIKE blfa1-bbbnr,
bbsnr LIKE blfa1-bbsnr,
begru LIKE blfa1-begru,
brsch LIKE blfa1-brsch,
bubkz LIKE blfa1-bubkz,
datlt LIKE blfa1-datlt,
dtams LIKE blfa1-dtams,
dtaws LIKE blfa1-dtaws,
erdat LIKE lfa1-erdat,
ernam LIKE lfa1-ernam,
esrnr LIKE blfa1-esrnr,
konzs LIKE blfa1-konzs,
ktokk LIKE lfa1-ktokk,
kunnr LIKE blfa1-kunnr,
land1 LIKE blfa1-land1,
lnrza LIKE blfa1-lnrza,
loevm LIKE blfa1-loevm,
name1 LIKE blfa1-name1,
name2 LIKE blfa1-name2,
name3 LIKE blfa1-name3,
name4 LIKE blfa1-name4,
ort01 LIKE blfa1-ort01,
ort02 LIKE blfa1-ort02,
pfach LIKE blfa1-pfach,
pstl2 LIKE blfa1-pstl2,
pstlz LIKE blfa1-pstlz,
regio LIKE blfa1-regio,
sortl LIKE blfa1-sortl,
sperr LIKE blfa1-sperr,
sperm LIKE blfa1-sperm,
spras LIKE blfa1-spras,
stcd1 LIKE blfa1-stcd1,
stcd2 LIKE blfa1-stcd2,
stkza LIKE blfa1-stkza,
stkzu LIKE blfa1-stkzu,
stras LIKE blfa1-stras,
telbx LIKE blfa1-telbx,
telf1 LIKE blfa1-telf1,
telf2 LIKE blfa1-telf2,
telfx LIKE blfa1-telfx,
teltx LIKE blfa1-teltx,
telx1 LIKE blfa1-telx1,
xcpdk LIKE lfa1-xcpdk,
xzemp LIKE blfa1-xzemp,
vbund LIKE blfa1-vbund,
fiskn LIKE blfa1-fiskn,
stceg LIKE blfa1-stceg,
stkzn LIKE blfa1-stkzn,
sperq LIKE blfa1-sperq,
adrnr LIKE lfa1-adrnr,
mcod1 LIKE lfa1-mcod1,
mcod2 LIKE lfa1-mcod2,
mcod3 LIKE lfa1-mcod3,
gbort LIKE blfa1-gbort,
gbdat LIKE blfa1-gbdat,
sexkz LIKE blfa1-sexkz,
kraus LIKE blfa1-kraus,
revdb LIKE blfa1-revdb,
qssys LIKE blfa1-qssys,
ktock LIKE blfa1-ktock,
pfort LIKE blfa1-pfort,
werks LIKE blfa1-werks,
ltsna LIKE blfa1-ltsna,
werkr LIKE blfa1-werkr,
plkal LIKE lfa1-plkal,
duefl LIKE lfa1-duefl,
txjcd LIKE blfa1-txjcd,
sperz LIKE lfa1-sperz,
scacd LIKE blfa1-scacd,
sfrgr LIKE blfa1-sfrgr,
lzone LIKE blfa1-lzone,
xlfza LIKE lfa1-xlfza,
dlgrp LIKE blfa1-dlgrp,
fityp LIKE blfa1-fityp,
stcdt LIKE blfa1-stcdt,
regss LIKE blfa1-regss,
actss LIKE blfa1-actss,
stcd3 LIKE blfa1-stcd3,
stcd4 LIKE blfa1-stcd4,
ipisp LIKE blfa1-ipisp,
taxbs LIKE blfa1-taxbs,
profs LIKE blfa1-profs,
stgdl LIKE blfa1-stgdl,
emnfr LIKE blfa1-emnfr,
lfurl LIKE blfa1-lfurl,
j_1kfrepre LIKE blfa1-j_1kfrepre,
j_1kftbus LIKE blfa1-j_1kftbus,
j_1kftind LIKE blfa1-j_1kftind,
confs LIKE lfa1-confs,
updat LIKE lfa1-updat,
uptim LIKE lfa1-uptim,
nodel LIKE blfa1-nodel.
DATA: END OF vendor_file_x.
FIELD-SYMBOLS: <field>,
<field_1>.
DATA: delim TYPE x VALUE '09'.
DATA: fld_chk(4096),
last_char,
quote_1 TYPE i,
quote_2 TYPE i,
fld_lth TYPE i,
columns TYPE i,
field_end TYPE i,
outp_rec TYPE i,
extras(3) TYPE c VALUE '.,"',
mixed_no(14) TYPE c VALUE '1234567890-.,"'.
OPEN DATASET p_file FOR INPUT.
DO.
READ DATASET p_file INTO data_tab-data.
IF sy-subrc = 0.
APPEND data_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
* count columns in output structure
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
columns = sy-index.
ENDDO.
* Assign elements of input file to internal table
CLEAR vendor_file_x.
IF columns > 0.
LOOP AT data_tab.
DO columns TIMES.
ASSIGN space TO <field>.
ASSIGN space TO <field_1>.
ASSIGN COMPONENT sy-index OF STRUCTURE vendor_file_x TO <field>.
SEARCH data_tab-data FOR delim.
IF sy-fdpos > 0.
field_end = sy-fdpos + 1.
ASSIGN data_tab-data(sy-fdpos) TO <field_1>.
* Check that numeric fields don't contain any embedded " or ,
IF <field_1> CO mixed_no AND
<field_1> CA extras.
TRANSLATE <field_1> USING '" , '.
CONDENSE <field_1> NO-GAPS.
ENDIF.
* If first and last characters are '"', remove both.
fld_chk = <field_1>.
IF NOT fld_chk IS INITIAL.
fld_lth = strlen( fld_chk ) - 1.
MOVE fld_chk+fld_lth(1) TO last_char.
IF fld_chk(1) = '"' AND
last_char = '"'.
MOVE space TO fld_chk+fld_lth(1).
SHIFT fld_chk.
MOVE fld_chk TO <field_1>.
ENDIF. " for if fld_chk(1)=" & last_char="
ENDIF. " for if not fld_chk is initial
* Replace "" with "
DO.
IF fld_chk CS '""'.
quote_1 = sy-fdpos.
quote_2 = sy-fdpos + 1.
MOVE fld_chk+quote_2 TO fld_chk+quote_1.
ELSE.
MOVE fld_chk TO <field_1>.
EXIT.
ENDIF.
ENDDO.
<field> = <field_1>.
ELSE.
field_end = 1.
ENDIF.
SHIFT data_tab-data LEFT BY field_end PLACES.
ENDDO.
APPEND vendor_file_x.
CLEAR vendor_file_x.
ENDLOOP.
ENDIF.
CLEAR data_tab.
REFRESH data_tab.
FREE data_tab.
Rob -
To import addresses, need format of tab delimited file
I am trying to import addresses from my G3 PB Mozilla App. I exported addresses on G3 to both ldif and tab-delimited files and then attached to an email message which I sent to myself. I received email on Mac mini, but the 2 files showed up inline, not as attachments. I copied the ldif portion to a text file; ditto for tab-delimited. I tried importing into Address Book, but got message that format was not valid.
Can't I just edit the tab-delimited file in TextEdit, save as RTF, and get Address Book to recognize the data?
Thanks,
OwenHi, Did you get solution for this? Please let me know as I'm looking for the same solution. The Bank requirement is to generate a Tab delimited file but the RFFOGB_T with Format GB_BACS issues the output as below...
Required by Bank:
692532 73855963 RRS P R BACKLEY 169.91 GSLV
294518 99855581 CETS PRITECTIIN 799.72 GSLV
The output I get from SAP/DMEE:
........1........2........3........4........5........6....
VOL1000004 ....953312
1 <CR/LF>
HDR1A953312S 195331200000400010001 10040 100420000000
<CR/LF>
HDR2F0200000100 00
<CR/LF>
UHL1 10041999999 000000001 DAILY 000
<CR/LF>
6010392865540009960062063474662 00000115000ABC UK Ltd. 0
1465 <CR/LF>
6006206347466201760062063474662 00000115000SAPBACS0000003306 C
ONTRA ABC UK LTD. <CR/LF>
EOF1A953312S 195331200000400010001 10040 100420000000
<CR/LF>
EOF2F0200000100 00
<CR/LF>
UTL10000000115000000000011500000000010000001
<CR/LF>
END
<CR/LF>
<END>
Rgds,
Stan -
Hi All,
I am trying to create a tab delimited file using Sender File adapter using <b>File content Conversion in Adapter Module</b>. I want a constant space beteween the fields of length 8 spaces. When i use ' ' as field seperater , the file that is generated is <b>19' 'Stringtest14,Hiring' '09/03/2007' 'Managing Dir, Operations</b>. I want the file without colons i.e <b>19 Stringtest14,Hiring' 09/03/2007 Managing Dir, Operations</b>.
Please Advice...
Regards,
XIerHi Xler
<b>content conversion parameters ,, just like</b>
Recordset structure = DT_PRY,*
DT_PRY.fieldnames = ID,empname,empno,country
DT_PRY.fieldSeparator = '0x09' (tab delimited)
DT_PRY.endSeparator = 'nl'
<b>
The FCC...</b>
Document Name : MT_PRY
Document Namespace : http://product.com/prvsoup
Recordset Name : recordset
Recordset structure = DT_PRY,*
DT_PRY.fieldnames = ID,empname,empno,country
DT_PRY.fieldSeparator = '0x09'
DT_PRY.endSeparator = 'nl'
ignoreRecordsetName = true
http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
<b>can take the help of this blog</b>
/people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
<b>Conversion agent</b>
/people/william.li/blog/2006/03/17/how-to-get-started-using-conversion-agent-from-itemfield
/people/paul.medaille/blog/2005/11/18/conversion-agent-a-free-lunch
/people/alexander.bundschuh/blog/2006/03/14/integrate-sap-conversion-agent-by-itemfield-with-sap-xi
/people/paul.medaille/blog/2005/11/17/more-on-the-sap-conversion-agent-by-itemfield
Thanks!
Questions are welcome here!!
<b>Also mark helpful answers by rewarding points</b>
Regards
Abhishek Agrahari -
Opening a tab delimited file and replacing a space
Hi,
I am trying to open a tab delimited file with 4 columns and corresponding values under it. If no value under the column, 0 should be replaced. I used the StringTokenizer and the split methods, but this doesnt seem to work. Any ideas?
E.g
Title1 Title2 Title3
4 7
5 2
SHould be like this:
Title1 Title2 Title3
4 0 7
0 5 2
Thanks..The answer, however, is no. Java is a strongly typed
language; there is no predefined manner in which a
String object can be casted to an Integer object
because a String is not an Integer.
However, if you'd like to create an Integer based on
the contents of a String, you can pass the String to
the Integer.parseInt(String) method. That method
will do one of two things: return the Integer object
representing the integer contained within the String
(if the String represents an Integer) or throw a
NumberFormatException (if the String is not an
Integer).Hi,
Thanks tvynr for your reply. Ok first things, sorry, I had written that post in a hurry. Yes i dont usually put capital letters for my fields. Also i did mean using the add method. Not the get..
And yes I have tried various different type castings. Just to see if one of them would work. And yes i did try Integer.parseInt() by passing in the string to get back its contents as an integer. *And yes the String content is an integer.
Heres a snippet of my code -
List ArrScore1 = new ArrayList(); //List to store Score in one Array
List ArrScore2 = new ArrayList(); //List to store same Scores in another Array. FOr comparisions
List SCORES = new ArrayList();
int dist1,dist2 = 0;
float distance,percent;
while ((record = br.readLine())!= null) //To read from a file line by line from first line
recCount++;
String rec = record;
String [] ScoreScop = rec.split("\t");
ArrScore1.add(ScoreScop[4]));
ArrScore2.add(ScoreScop[4]);
} //End of While loop
System.out.println("Total Records: " + recCount);
for (int i=0; i<ArrScore1.size(); i++)
for (int j = i + 1; j < ArrScore2.size(); j++)
dist1 = Integer.parseInt(ArrScore2.get(j)); //Error I get here is is Cannot resolve symbol. What does this mean exactly?
dist2 = Integer.parseInt(ArrScore1.get(i)); //Same error
distance = dist1/dist2;
percent = distance * 100;
SCORES.add(percent); //Again same error
} //End of j loop
} // End of i loop
I have included all the necessary packages as well. Including :
import java.io.*;
import java.util.*;
import java.lang.*;
import java.util.List;
import java.util.ArrayList;Any idea what I am doing wrong here? -
Inserting a tab delimited file
Hi there,
I am inserting data into a database from text files. I can easily do this in sql with csv files but I need to be able to do it with tab delimited files. I know you can do this from the built in Oracle tool (I am using express edition) but I was wandering if anyone know how to write a script for it in sql.
Any help would be greatly appreciated.
ThanksIf you are using SQL Loader to load the data use below syntex
FIELDS TERMINATED BY X'9'
The X'9' is Hexadecimal Format -> X
and Hex 9 is the ASCII code of the TAB character.
Check out the link for more details:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:533222350291
Regards
Arun -
Is there any methodology whereby a file can be exported, or saved, as a Tab Delimited File?
ThanksSelect All
Copy
Paste in a Pages document
Export as text.
Other way (my preffered one) :
Select All
Copy
run this Script :
--[SCRIPT clipboard2textFile]
Enregistrer le script en tant que Script :clipboard2textFile.scpt
déplacer le fichier créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:
Copiez la table à exporter dans le Presse-papiers.
menu Scripts > clipboard2textFile
Le script créera un fichier TSV (valeurs séparées par TAB).
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
+++++++
Save the script as a Script :clipboard2textFile.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:
Copy the table to export into the clipboard
menu Scripts > clipboard2textFile
The script will create a TSV file (Tab separated values).
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
+++++++
Yvan KOENIG (VALLAURIS, France))
2009/07/07
2010/01/10 : Corrigé quelques coquilles dans les explications
--=====
on run
try
set enTexte to the clipboard as text
set fName to (do shell script "date " & quote & "+_%Y%m%d-%H%M%S" & quote) & "." & "txt"
set p2d to path to desktop
tell application "System Events" to make new file at end of p2d with properties {name:fName}
write enTexte to file ((p2d as text) & fName)
on error
if my parleAnglais() then
error "The clipboard doesn’t contain text data. Maybe you selected a Numbers sheet !"
else
error "Le presse-papiers ne contient pas de données texte. Vous avez peut-être copié une feuille de Numbers !"
end if
end try
end run
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mardi 16 février 2010 21:57:42
Maybe you are looking for
-
Not booting from 10.4.8 volumes after upgrade from 10.4.7
I'm sorry to report that my aged G4 450 MHz AGP with 4 internal Hard disk drives no longer boots from any of the 2 volumes upgraded to Mac OS X 10.4.8 as soon as it was started from another volume! All was working fine as long as 10.4.7 was installed
-
FYI Notification after final approval using AME
Hi, We have a requirement where we need to send a FYI notification to a group of people after final approval. Could you please guide if it can be done with the help of AME or not. If yes can you please tell me the detail steps. Regards, Rakesh.
-
How to draw the picture in labview 8.6 and how to simulate the same
Hi Iam using Labview8.6 and we need to draw the picture or import the autocad drawing and we need to simulate the same. If anybody knows please reply me.
-
I bought this movie on itunes, but i cant find it in the "movies" section.
i bought this movie on itunes, but i cant find it in the movies section. but i did pay for it.
-
I have a problem that for some people is easy to resolve. Problem: I have 2 fields in a pdf file. the 1ste field is a selection field. named "Categorie" With that information the second field gives a result. "categorie found" Example: CAT1 = 20 € CAT