How to handle a comma in a field in CSV file during FCC ?

Hi,
I am having a requirement where we have to convert a CSV file into XML using File Content Conversion . The issue is one of the field in the file is having a comma inside. So the XML parser is taking it as a field separator and throwing an error.
The contents of the file are as follows:
"02975859","New Key","9","Failed, rejected by RTI server"
How to handle a comma inside field "Failed, rejected by RTI server".
Any help would be appreciated.
Regards
Pravesh

Hi ,
You have to write an java mapping programm to perdromance this task , in a estandar way i think is not possible , because the fiel adapter have just one option for the delimiter character.
Here's some code that could help you
Supouse a file in this way:
1,rahul,siemens,mumbai
2,consultant,12032005
1,viswanath,sisl,hyderabad
2,systemeng,23052005
package TXTMapping;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Map;
import com.sap.aii.mapping.api.StreamTransformation;
public class TMapping implements StreamTransformation {
private Map map;
public void setParameter (Map param){
map = param;
public void execute (InputStream in, OutputStream out){
try{
out.write("<?xml version ='1.0' encoding='UTF-8'?>".getBytes());
out.write("<ns0:Output_Data xmlns:ns0=\"urn:javamapping_test\">".getBytes());
String line = null;
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer();
while((line = bin.readLine())!= null){
String Company = null;
String Name = null;
String Place = null;
String Desgn = null;
String Since = null;
char[] str= new char[100];
str = line.toCharArray();
String[] Data = new String[10];
int S1 = 0;
int s2 = 2;
for (int i=2; i<line.length(); i++)
if (str<i>==',' && str[0]=='1')
Data[S1]= line.substring(s2,i);
S1=S1+1;
s2 = i+1;
if (i == line.length()-1 && str[0] == '1')
Data[S1]= line.substring(s2,i+1);
Name = Data[0];
Company = Data[1];
Place = Data[2];
out.write ("<Data>".getBytes());
out.write ("<Header>".getBytes());
out.write (("<Name>"Name"</Name>").getBytes());
out.write (("<Company>"Company"</Company>").getBytes());
out.write (("<Place>"Place"</Place>").getBytes());
out.write ("</Header>".getBytes());
if (str<i>==',' && str[0]=='2')
Data[S1]= line.substring(s2,i);
S1=S1+1;
s2 = i+1;
if (i == line.length()-1 && str[0] == '2')
Data[S1]= line.substring(s2,i+1);
Desgn = Data[0];
Since = Data[1];
out.write ("<Item>".getBytes());
out.write (("<Designation>"Desgn"</Designation>").getBytes());
out.write (("<Since>"Since"</Since>").getBytes());
out.write ("</Item>".getBytes());
out.write ("</Data>".getBytes());
out.write("</ns0:Output_Data>".getBytes());
catch(Throwable t){
t.printStackTrace();

Similar Messages

  • How do I have Numbers recognise comma delimited information in a .csv file?

    I have a .csv file with column information delimited by commas, but Numbers does not seem to have a way to automatically recognise and format. 

    Numbers should correctly open a comma separated value file and distribute it into columns and rows if your localization uses a point (not a comma) for the decimal. If your localization uses a comma for the decimal, a CSV file must use semicolons for separating the data.  Given your question, I can only assume this is your problem. If so, you need to convert the separating commas to semicolons and do so without converting commas in the data (such as in a text field).  You may also need to convert decimal points to commas without converting text periods to commas.  There may be a script to do this but if you need to do this only once in a blue moon you could change your localization to US (or equivalent), import the file, then change it back.
    I have a script for converting CSV to tab separated without affecting commas within text (text with commas is supposed to be enclosed by quotes in a CSV, that is how it knows not to convert them).  A simple Find/Replace using TextEdit won't be so careful. But if your localization uses commas for decimals and you have any decimal numbers, the script choke on those extra commas.

  • Load data with SQL Loader link field between CSV file and Control File

    Hi all,
    in a SQL Loader control file, how do you specify link with field in CSV file and Control file?
    E.g. if I wat to import the record in table TEST (col1, col2, col3) with data in csv file BUT in different position. How to do this?
    FILE CSV (with variable position):
    test1;prova;pippo;Ferrari;
    xx;yy;hello;by;
    In the table TEST i want that col1 = 'prova' (xx),
    col2 = 'Ferrari' (yy)
    col3 = default N
    the others data in CSV file are ignored.
    so:
    load data
    infile 'TEST.CSV'
    into table TEST
    fields terminated by ';'
    col1 ?????,
    col2 ?????,
    col3 CONSTANT "N"
    Thanks,
    Attilio

    With '?' mark i mean " How i can link this COL1 with column in csv file ? "
    Attilio

  • How can I add links to open xml and csv files stored in another location? Please advice how to place links in my frame maker document?

    Hi,
    I would like to know as to how can I add links to open xml and csv files stored in another location? Please advice how to place links in my frame maker document?
    Kindly advice.
    Thanks
    Priya

    Special > Hypertext > Command "open document" will do its best to open the target document inside FrameMaker, which may not be much help; Special > Hypertext > Command "message …" will use the application you specify. The user guide for 7.0 says this about absolute links, and I don't think anything has changed since:
    For example, to start PaintBrush and open the Ship.pcx file on drive C you would use the command message system pbrush.exe C:/Ship.pcx
    I've not often used a relative link, and not recently: the same source says
    folder levels are separated by a slash / even in Windows and Mac
    [relative links] FrameMaker searches for a relative pathname beginning in the folder that contains the current document
    [absolute links] FrameMaker searches for an absolute pathname beginning at the top of the file system. In Windows, the absolute pathname begins with the drive specifier, a colon and a slash.

  • How to handle "Validation failed for the field - Tax code" issue?

    We had mass uplaod the order that create on Mar with tax code effective date on Apr. Now we would like return on this order  and getting error of "Validation failed for the field - Tax code". How to handle this issue?

    Hi
    You will have to check if the Tax_Code of RMA being received is the same as the one in the related sales order.
    If not you will need to use the same tax_code.
    Refer below document : Doc ID 1584338.1

  • How to solve extra commas in CSV files in FCC..!!

    Hi,
    I have the CSV file with comma(,) separator which has around 50 fields. Among them there were some description fields which has comma (ex: karan,kumar) which has to come as a single field and comes as 51 fields instead of 50.
    Due to this, im facing problem at File content conversion and it is failing with error " ERROR converting document line no. 8534 according to structure 'Header':java.lang.Exception: ERROR in configuration / structure 'Header.': More elements in file csv structure than field names specified!
    We have around 10 fields which comes in this way.Any idea how to solve this issue?
    Thanks
    Deepthi.

    Hello Deepthi,
                 The option here is use fieldFixedLengths instead of fieldSeparator. By this way evethough you have more fields in file than given filednames, it will not trigger any error. (But this one will still keep the commas which you might not need in the xml structure, though you can replace these in mapping anyway this is one solution )
    enclosureSign option you can try, but you need do include the delimeter in you file structure, which is again a troublesum.
    eg:- field1, | karan,kumar|,fieldn
    In case you are familier with Adapter Module you can do it  easily, but its a final option as far i am concern.
    Regards,
    Prasanna

  • How to handle ' " '(double quotes) in .csv file during migration

    I am facing problem in migrating data from sql server 2000 into oracle via .csv file using sql loader.
    1>How should i migrate the string which contains ' " ' (double quotes) characters,
    as i am enclosing the string in ' " ' in .ctl file (enclosed by ' " ').
    is there any syntax in the control file which can migrate the ' " '(double quotes) as it is as the data in the files is 50000 records .?
    Thank you..

    Yes this is correct.
    but problem will occur when e.g check the foll. string.
    (1001,And I quote "This, will work")
    Here it is a comm(,) in b/w "This and will".
    due to this sqlldr interpret it as end of field. and throws an error.
    I had gone through expert one on one oracle, what it maintioned as,
    put an extra double quotes( " ) like " " to enclosed the double quoted string.
    This works fine. For small data it can be done manually.
    But for large data what condition can be put in the ctl file to achieve this?
    or is there any other way to achieve this?
    Thank you.

  • Comma and quote problem in csv file

    Hi
    My requirement is to append data in an csv file. This is Proxy to File FCC Scenario. for some of the fields from proxy which contains comma(,) and also double-quote("). for these fileds the in the csv file it is spiting in to two columns and appending in to the next column. and the double-quote symbol is not inserting in the csv file.
    1. why the double-quote(") is not inserting in to the csv file columns?
    2. how to over come the comma problem? I want that particular file need to append in one column only.
    Thanks
    Vankadoath

    hi vankadoath,
    Were you able to solve comma issue in CSV file.
    Even i am facing similar issue.....
    wheneever there is a comma in field, it is updating data after comma into next field.
    If anybody has solution for the same.......
    pls suggest the same............
    santosh.
    Edited by: santosh koraddi on Jan 20, 2011 9:44 PM

  • SQL*Loader - How to load only a few columns from a .csv file to ora table

    Hi there,
    Could anyone please let me know how to load few columns from a .csv
    file into a oracle table using SQL*Loader.
    I know how to create a .dat and .ctl file and run the sql loader.
    Suppose I have a .csv file with
    col1, col2, col3, col4
    and I only need to load col1 and col3 into col_a and col_b respectively
    in table_a?
    structure of table_ a
    col_a,
    col_b
    Please advice

    Try like..it i will work..
    LOAD DATA
    INFILE 'test.txt'
    LOAD DATA
    TRUNCATE INTO TABLE T1
    FIELDS TERMINATED BY ','
    (col1,
    col2 FILLER,
    col3,
    col4 FILLER
    )

  • Problem With Crystal Reports Reading Date Fields From CSV File

    I have a date field in a CSV file in the format 06/28/09 17:23:55.523. When I use ODBC the configuartion picks it up a character field. I overright the recommendation type by specifing it is a date field but whne I bring the data into crystal reports the dates are blanks. Any suggestions on how to get around this problem. I need to use the date for selection records.
    Phasor

    The question was answered under another thread. I had to use the split commmand to get rid of the fractions of a second

  • Import List Items with Managed Metadata Field from CSV File

    Hello,
    I try to import list items from a CSV File. Most of the fields are populating correctly except the Managed Metadata Field. I found multiple examples on how to set Managed Metadata Fields with Powersehll, but unfortunately I couldnt get it running.
    The CSV File holds values for the Metadata Column, this value should be checked against the Metadata in the Termstore. If this Term is existent, then it should set the fields value, if it is not existant then it should add the term from the CSV File to the
    Term Set in the Term Store. Can anybody give me a tip on how to do this? This is what I have, where Line 4 holds the Metadata:
    $Siteurl = "http://siteUrl"
    $Rootweb = New-Object Microsoft.Sharepoint.Spsite($Siteurl);
    $Webapp = $Rootweb.Webapplication
    $listName = "Catalogue"
    $listWeb = Get-SPWeb $Siteurl
    $list = $listWeb.Lists[$listName]
    $pfad1 = "c:\temp\Servers.csv"
    $content = import-csv -Delimiter ";" -Path $pfad1 
    foreach ($line in $content) {
    $newItem = $list.Items.Add()
    $newItem["Field 1"] = $line.1
    $newItem["Field 2"] = $line.2
    $newItem["Field 3"] = $line.3
    $newItem["Field 4"] = $line.4
    $newItem.Update()
    write-host $line.Title imported
    Thanks!!

    Hi Jimmie,
    From your description, when importing list from csv to SharePoint site, you would like to compare if Managed Metadata column exists in term store, and return yes value, if not, add it to term store.
    That might need script to achieve. You need to import list at first, then get value from term store, and compare with the list. Change the list field per comparison result, then add new value to term store.
    However, there might some workaround to meet your requirement. Not surly understand, so I find some references for you:
    If you would like to export Term Set to CSV from SharePoint 2013, then you could compare it:
    http://gallery.technet.microsoft.com/office/PowerShell-for-SharePoint-a838b5d0#content
    If you would like to query SharePoint 2013 Managed metadata term store using JavaScript:
    http://sharepoint.stackexchange.com/questions/60045/query-sp2013-managed-metadata-term-store
    http://stackoverflow.com/questions/13858962/getting-all-the-term-stores-in-sharepoint-2010-web-services-or-client-side-obje
    If you would like to synchronize, import or copy term store & managed metadata in SharePoint between environments:
    http://www.matthewjbailey.com/synchronize-import-or-copy-term-stores-managed-metadata-in-sharepoint/
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to upload data into a database from a csv file in a jsp app?

    I can write a HTML form to let users to post a csv file and store it in the web server, then how could I process the file to load the data into a View Obj or an Entity Obj without manually parsing the csv files? Any jsp or java code samples that will do something like the "sqlload" in sqlplus?
    I'm using JDev 3.1.1.2. Thanks.

    Navy_Coder wrote:
    6 zebras.But you must marry his eldest daughter as well, for that dowry.

  • How to update a specific cell value in a CSV file.

    Hi
    I would like to know whether it is possible in openscript to update a cell value of the CSV file.
    For example if the test script requires to update the cell of 6th row and 8th column, then how to achieve through openscript API?
    Please kindly let me know.

    Hi,
    Hope this helps!
    Table table;
    String[] rowvalus;
    int targetRow=5,targetColumn=7;
    * Note: Rows and columns are 0-based index.
    table =utilities.loadCSV("C:\OracleATS\OFT\DataBank\Test.csv");
    rowvalus=table.getRows().get(targetRow).getAll();
    info("Before change :"+rowvalus[targetColumn]);
    rowvalus[targetColumn]="NewValue";
    utilities.saveCSV(table, "C:\OracleATS\OFT\DataBank\Test.csv", true);
    table =utilities.loadCSV("C:\OracleATS\OFT\DataBank\Test.csv");
    rowvalus=table.getRows().get(targetRow).getAll();
    info("After change :"+rowvalus[targetColumn]);
    Note:- Please first take the backup of your CSV file before using this code snippet
    Thanks
    -POPS

  • How do I remove e-mail addresses from a csv file referencing a numbers doc

    Greetings! I hope someone out there can help me. I'm not exactly a genius when it comes to numbers...
    My Issue:
    I'm attempting to sending out a large e-mail blast via software called hoolie, it seems to be working amazingly well except for the fact that I've reached our Gmail accounts daily limit which I had zero idea existed.
    So about 1100 emails were sent and I still have to send about 1500 emails left to be sent. The software has no ability to resend to the failed e-mail addresses, so I'm left to my own devices...
    My Goal:
    I want to be able to subtract out the 1100 e-mail address from the csv file I have with all the addresses. Once I subtract out the e-mail addresses I can then resend the blast and throttle it so it takes a day or so and won't freak out google gmail...
    How can I accomplish this? I have the orginal CSV file with all the names and e-mail addresses and I have a new numbers doc in which I pasted the e-mails that were succesfully sent...
    Thoughts? Suggetsions?
    thanks in advance!

    Are you suggesting that it sent it to a random sample of the email addresses, that it did not start at the beginning and go row by row until it failed?  If that is the case, you can import the CSV file into Numbers, paste your list of sent addresses in another column or another table of that document, then use COUNTIF to look for duplicates.
    The best I can do is an example.Your table will no doubt be different so you'll have to rejigger the formula.
    Importing your CSV file will create column B
    Insert two new columns, C and D
    Use Copy/Paste to copy/paste your list of sent addresses from your other document into column D
    The formula in column C is =IF(COUNTIF(D,B)>0,"Was Sent","")
    Once it has done its thing, sort by column C to get all the "Was Sent" rows together. Delete them. Delete column C, Delete column D. Share as a CSV.

  • Powershell: How to change the header name in a imported CSV file

    HI All,
    I have a csv file in which I want to change the headers names in powershell.
    oldnames are name,id
    newnames I want to give are: company and transit respectively.
    Following is what I wrote in script:
               $a = import-csv .\finalexam\employees.csv -header name,id'
                       foreach ($a in $as[1-$as.count-1])  // I used 1 here because I want it to ignore the  exiting headers.
                      { $_.name -eq company, $_.id -eq transit}
    I think this not entirely correct way to do this. Can someone show me how to fix this.
    Regards
    SQL 75

    If you're not an experienced PowerShell programmer, I recommend editing the file in a text editor and changing the name that way.
    -- Bill Stewart [Bill_Stewart]

Maybe you are looking for