Conversion from txt  to csv

Hi,
As a part of our project we are generating a text file containing the query output, it is in the following format..
| contributor | x | url |
===========================================================================
| _:b0 | "Norm Walsh" | <http://norman.walsh.name/> |
| _:b1 | "Ebiquity research group UMBC" | <http://ebiquity.umbc.edu/v2.1/blogger/> |
| _:b2 | "Orri Erling" | <http://www.openlinksw.com/weblogs/oerling/> |
| _:b3 | "John Breslin" | <http://www.johnbreslin.com/blog/> |
We need to convert this into csv file. We have tried writing a java code for this, but are facing a problem there as it is considering each space as a newline and also all the rows are not coming in a new line.
We are running all the codes on eclipse platform.
Relevant codes are:
          FileReader reader = new FileReader("C:\\track1.txt");
          Scanner dumpfile = new Scanner(reader);
     PrintWriter out = new PrintWriter("C:\\output.txt");
               while (dumpfile.hasNext())
                    out.print((dumpfile.next().replace("|",",").replace('-', ' ').replace('=', ' ')));
and
FileReader reader1 = new FileReader("C:\\output.txt");
     Scanner dumpfile1 = new Scanner(reader1);
     PrintWriter out1= new PrintWriter("C:\\csvfile.txt");
     while (dumpfile1.hasNext())
          out1.println(dumpfile1.next().replace(",,","     "));
Can anyone give us a solution ..pls
Regards,

We want the output in the following format(csv format):
contributor , x , url
_:b0 , "Ivan Herman",<http://ivanherman.wordpress.com/tag/work-related/semantic-web/>
_:b1 , "Dave Beckett",<http://journal.dajobe.org/journal/>
_:b2,"Uldis Bojars", <http://captsolo.net/info/>
_:b3, "Peter Mika",<http://tripletalk.wordpress.com/>
We have made a few changes to the code now.We added the following code snippet:
                  FileReader reader1 = new FileReader("C:\\output.txt");
                   Scanner dumpfile1 = new Scanner(reader1);
                  PrintWriter out1= new PrintWriter("C:\\csvfile.txt");
                  while (dumpfile1.hasNext())
                      out1.println(dumpfile1.next().replace(",,","\n"));
                  }but now for the 1st 2 rows the colomns are shifted to the right by 1 cell. The output is as follows in excel:
     contributor     x     url
     _:b0     OraLassila     <http://www.lassila.org/blog/>
_:b1     LeighDodds <http://xmlarmyknife.org/blog/>     
_:b2     KingsleyIdehen <http://www.openlinksw.com/blog/~kidehen/>     
_:b3     LeighDodds <http://ldodds.com/blog/>
In csv it is as follows:
,contributor,x,url,
,_:b0,"IvanHerman",<http://ivanherman.wordpress.com/tag/workrelated/semanticweb/>
_:b1,"DaveBeckett",<http://journal.dajobe.org/journal/>
_:b2,"UldisBojars",<http://captsolo.net/info/>
_:b3,"PeterMika",<http://tripletalk.wordpress.com/>     
Comma at the beginning in the first two lines must be removed using java code. If anyone could help me out with this, it will be very helpful for me.
Regards

Similar Messages

  • Insert Data into Table from TXT or CSV file !!!!!

    Dear All,
    Recently I have started working on APEX. In Oracle Forms, we used to use TEXT_IO for inserting records into tables from txt files. Now I want to do the same thing in apex 3.2. How can I insert data into tables from txt of csv files.
    Waiting of your valuable suggestions.
    With kind regards,
    Yousuf.

    Yousuf
    wwv_flow_files is used by APEX to hold uploaded files.
    If you incorporate a file browse item on you page, browse for the selected file, then submit the page (having the PL/SQL process described as an on suibmit process) then what I detailed should work.
    If you don't need users to have access to this then just go to Home>Utilities>Data Load/Unload in APEX and there is a handy load utility there that does it all for you.
    Cheers
    Ben

  • Conversion from xml to csv using xsl

    hi i am converting from xml to csv using xsl i am getting the extra junk character(space) in the csv file.below i written the xml file and xsl file
    xml file
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <?xml-stylesheet type="text/xsl"?>
    <DOCUMENTS>
         <FILE>
         <DOCUMENT>
              <BUSINESS>finance</BUSINESS>
              <PROGRAM>CM</PROGRAM>
              <PROJECT>Testing Area</PROJECT>
              <NAME>121940~1.doc</NAME>
              <TEXT>SQL</TEXT>
              <LINK>http://www.sql.org/</LINK>
         </DOCUMENT>
         <DOCUMENT>
              <BUSINESS>finance</BUSINESS>
              <PROGRAM>CM</PROGRAM>
              <PROJECT>Testing Area</PROJECT>
              <NAME>121940~1.doc</NAME>
              <TEXT>Information</TEXT>
              <LINK>http://google.com/</LINK>
         </DOCUMENT>
         <DOCUMENT>
              <BUSINESS>finance</BUSINESS>
              <PROGRAM>CM</PROGRAM>
              <PROJECT>Testing Area</PROJECT>
              <NAME>121940~1.doc</NAME>
              <TEXT>Configuration</TEXT>
              <LINK>http://msdn.microsoft.com/</LINK>
         </DOCUMENT>
         </FILE>
    </DOCUMENTS>
    xsl file
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text" indent="yes"/>
    <xsl:template match="DOCUMENTS">
    <xsl:text>Business,Program,Project,DocumentName,Textforlink,Hyperlink</xsl:text>
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="FILE">
    <xsl:value-of select="DOCUMENT/BUSINESS"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="DOCUMENT/PROGRAM"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="DOCUMENT/PROJECT"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="DOCUMENT/NAME"/>
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="DOCUMENT">
    <xsl:value-of select="','"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="TEXT"/>
    <xsl:value-of select="','"/>
    <xsl:value-of select="LINK"/>
    </xsl:template>
    </xsl:stylesheet>
    for converting to csv i am using java program.
    please go through it.

    <xsl:value-of select="','"/>That's not the correct way to output a literal comma. Just write the comma directly, or use xsl:text. And don't put in those line breaks either. You can reduce the rule for FILE to something like this:
    xsl:template match="FILE">
    <xsl:value-of select="DOCUMENT/BUSINESS"/>, <xsl:value-of select="DOCUMENT/PROGRAM"/>, <xsl:value-of select="DOCUMENT/PROJECT"/>, <xsl:value-of select="DOCUMENT/NAME"/>
    <xsl:apply-templates/>
    </xsl:template>

  • Problem in file content conversion from XML to CSV

    Hi Experts,
    I am finding problem in file content conversion. I need to convert the following XML file into CSV file:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_CROSS_REF xmlns:ns0="urn:dabur:idoc2file:pos">
          <Update_type>2</Update_type>
          <PLU>00000000</PLU>
          <Cross_ref_PLU>7777777</Cross_ref_PLU>
          <Capture_PLU />
          <Package_size />
          <Package_desc />
      </ns0:MT_CROSS_REF>
    The output file data has to be like:
    2,00000000,7777777,,,,
    The problem I am facing is while specifying the content conversion parameters in communication channel i dont know what recordset structure i should mention as all the records are directly under root. If I mention recordset structure as "ns0:MT_CROSS_REF" and parameters as
    ns0:MT_CROSS_REF.fieldSeparator   ,
    ns0:MT_CROSS_REF.endSeparator    'nl'
    i get error in communication channel monitoring and no file is posted.
    Please help me as to what correct parameter i should mention in my case.
    Thanks,
    Regards,
    Yash

    Hi Chirag,
    I cannot change the xml file as it comes after mapping idoc to a message type. How can I add ROOT in the xml? My message type is like MT_CROSS_REF and it has those 6 fields as in the XML (Update_type, PLU etc.). I do the mapping of these fields from a IDOC and get the XML.
    I hope you got my point.
    Thanks,
    Yash

  • File conversion from text to CSV on present server without using GUI FM

    Hi Folks,
    This question may sound a bit weired but here it is. I have to convert a text file to csv using a SAP ABAP Report.
    The file is located on the presentation server and I am using FM's <b>GUI upload</b> and <b>GUI download</b> to do the same as the number of fields change and we perform some operations on the data coming from the text file. Actually, the csv file is supposed to act as a source system for SAP BI.
    Now my question is is there any other way by which we can do it without using the above function modules.
    Thanks
    Varun

    Hi,
    You upload the Text file using GUI_UPLOAD and now you will have the records in the internal table and then use GUI_DOWNLOAD to download the file in CSV format.
    Thanks
    PK

  • Is there an app i can use to listen or record conversations from i5s to i6plus ?

    is there an app i can use to listen or record txts and conversations from i6plus to i5s ?

    Maybe you should ask Apple.
    This forum is just users like yourself who can do absolutely nothing to change the way the iPhone works.
    Allan

  • I need how to load data from MS Excel(csv format) to NW Excel

    Hi,
    I am doing Migration project from SAP MS to NW Manually.
    I need how to load data from MS excel (csv format) to NW excel .
    For example 2008 budget data.
    Could you please help me in this.
    Thanks and Regards
    Krishna

    Hi,
    You need to create a transformation file and a conversion file if required. First upload the excel (csv) file into BPC using Manage Data and Upload File option.
    Create the transformation file (refer to the sap help  on how to define a transformation file). You need to specify the mapping correctly and include all your application dimensions and map them to appropriate columns of the flat file.
    Before running the import package, do validate the data in the flat file you uploaded into BPC with the transformation file you created.
    Thanks,
    Sreeni

  • How to create Store Procedure for export result select in .txt or .csv

    Hello,
    I'm using MSSQL Server.
    How to export results query  in .txt or .csv?
    But
    I can not use bcp or SQLCMD.

    1) linked server
    insert into txtsrv...table1#txt(CustomerNumber,CustomerName,EntryDate)
    select orderid, shipname, orderdate
    from Northwind..orders
    Set up the linked server
    Connecting a directory of text files as a linked server is easy.  Here’s how:
    In Windows, create a new directory for the linked server.  
    For this article, that directory will be E:\txtsvr. 
    Add that directory as a linked server with sp_addlinkedserver:
    EXEC sp_addlinkedserver txtsrv, 'Jet 4.0',
      'Microsoft.Jet.OLEDB.4.0', 'e:\txtsrv', NULL, 'Text' 
    That’s all that’s required to add the linked server txtsrv
     as a connection to the text files in E:\txtsvr, but there are
     no tables in txtsvr yet.  Also missing is a required file, schema.ini, 
    which must contain a description of each table’s format.  
    You can  learn more about schema.ini from the Microsoft MSDN Library,
     but for now, just use Notepad or your favorite text editor 
    to create the file e:\txtsrv\schema.ini as shown in Listing 1. 
     In addition, create an empty text file in e:\txtsrv named table1.txt.
    The file e:\txtsrv\table1.txt is now an empty table in the linked server txtsrv.  
    We can see that if we list information about all the tables in txtserv with 
    the system stored procedure sp_tables_ex:
    EXEC sp_addlinkedsrvlogin txtsrv, FALSE, Admin, NULL
    EXEC sp_tables_ex txtsrv
    Text files are tables
    We can’t issue a CREATE TABLE statement against this linked server, 
    but we have created a table easily enough.  We can, however, 
    run INSERT and SELECT queries, if we use the four-part naming 
    convention <server>…<table> (that’s three dots):
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Import txt or csv to iCal

    Hi all,
    I am trying to import a txt file for my favorite sports team but can't. Is this not possible to map this and import? I can convert the txt to csv or is there a utility to convert txt to ics? or csv to ics?
    thx..ron

    This script worked for someone else. Paste it into a script editor window, read through it, ask any questions, modify the script and/or your file as needed, backup your calendars and then run the script.
    AK
    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">--Convert CSV file to iCal events
    --Prompts for file, then processes
    --expects date,start time,end time,event name,xxxx,calendar name
    --eg 12/01/2006,20:30,22:00,Water Committee,,TestCal
    --change the various text item ns if data order in a file line is different
    --blank lines skipped
    --if other data present (eg location, notes ...) add a line in the tell calendar Calno loop
    --to include it eg set location to text item 5 of ThisLine
    set OldDelimiters to AppleScript's text item delimiters
    set LF to ASCII character 10
    set theFile to choose file with prompt "Select CSV calendar file"
    set theLines to read theFile
    set AppleScript's text item delimiters to {LF}
    set theLines to text items of theLines
    set AppleScript's text item delimiters to {","}
    repeat with ThisLine in theLines
    if (count of ThisLine) > 0 then --ignore blanks
    set StartDate to date (text item 1 of ThisLine & " " & text item 2 of ThisLine)
    set EndDate to date (text item 1 of ThisLine & " " & text item 3 of ThisLine)
    set CalName to word 1 of text item 6 of ThisLine
    tell application "iCal"
    set CalList to title of every calendar
    if CalName is in CalList then
    repeat with CalNo from 1 to count of CalList
    if CalName is item CalNo of CalList then exit repeat
    end repeat
    else
    set NewOne to make new calendar at end of calendars with properties {title:CalName}
    set CalNo to 1 + (count of CalList)
    end if
    tell calendar CalNo
    set newItem to make new event at end of events with properties {start date:StartDate}
    set summary of newItem to text item 4 of ThisLine
    set end date of newItem to EndDate
    end tell --calendar
    end tell --iCal
    end if
    end repeat
    set AppleScript's text item delimiters to OldDelimiters</pre>

  • Deprecated conversion from string constant to 'char*'

    Hi all
    I am working with strings and i cant figure out why the following
    warning appears at time of build.
    warning: deprecated conversion from string constant to 'char*'
    It appears for the line
    char *myName = "Apple.txt";
    Is there anyone who can help me?
    Help is welcome.
    Thanks in advance.

    Any reason why you aren't using NSString in place of char?
    char *myName = "Apple.txt";
    NSString *myName = @"Apple.txt";

  • Getting ÿþ as saved conversations from Lync in Outlook in Office 2013

    Hi,
    I've been trying to get to the bottom of this and have found similar posts, but no one seems to have an answer.
    When I IM someone using Lync 2013, they get a pop up notification but instead of the message they see ÿþ<.  Once they open the chat window, they can see my typed text.  Occasionally, certain people can't see the first line of my chat, but as
    long as they keep the chat window open, they can see everything new I type.
    All my conversations that are saved in outlook show ÿþ< for the text and are unreadable.  I've disabled the saving of conversations because they have become worthless.
    I believe it has to do with BOM but have not been able to find a way to fix this.
    If I copy a conversation from the chat window and paste it into Microsoft Word it shows ÿþ<, but if I paste it into notepad the conversation appears.
    (I had inserted a screenshot here, but am unable to because I am unable to figure out how to get my account "verified")
    I've tried changing the preferred encoding for outgoing messages: to Unicode (UTF-8) in Outlook, but this had no effect and I can't find a similar option in Lync 2013.
    (I had inserted a screenshot here, but am unable to because I am unable to figure out how to get my account "verified")
    I enabled logging for Lync and the event IDs that come up are 1, 11 and 12, to which I cannot find any information for at the moment.
    Any help and or suggestions would be appreciated.

    Hi,
    Did the issue happen only for you or for multiple users?
    Please try to delete Lync User Profile and information on Registry, then repair Office 2013.
    The path of Lync User Profile: %UserProfile%\AppData\Local\Microsoft\Office\15.0\Lync
    The path for information on Registry: HKCU\Software\Microsoft\Office\15.0\Lync\[email protected]
    Then test the issue again.
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • Auto delete everything but specified folder contents from txt file

    Hey Guys,
    I am brand new to using Powershell (like 48 hours into using it for work) and I've run into a bit of an issue.  I've only taken a programming concept classes so some of the stuff makes sense to me but a lot of it is new.  Basically I've made a
    script that automatically deletes any files over X amount of days.  My next step is to have an exceptions text that will have a list of folders that should not have its contents deleted.  This is what I have so far.
    $Date= Get-Date 
    $Days = "7"
    $Folder = "C:\publicftp\users"
    $LastWrite = $Now.AddDays(-$Days)
    #----- getting DO NOT DELETE listing from TXT ----#
    $Exceptions = Get-Content "c:\exclude.txt"
    $Files = Get-Childitem $Folder -Recurse -Exclude "c:\exclude.txt" | Where {$_.LastWriteTime -le "$LastWrite"}
    foreach ($File in $Files)
        if ($File -ne $NULL)
            Remove-Item $File.FullName -Exclude $Exceptions | out-null
    I've seen a lot of threads that show how to auto delete contents or how to exclude specific file types but I haven't seen an answer to my particular problem.  Any help would be greatly appreciated!  Thanks!

    Hi Rabbot,
    The script below may be also helpful for you, and uses the -whatif parameter in Remove-Item cmdlet, which doesn’t actually remove anything but simply tells you what would happen if you did call Remove-Item.
    $Exceptions = @()
    Get-Content "c:\exclude.txt" | foreach{
    $Exceptions += $_} #store the exception file to array
    $Folder = "C:\publicftp\users"
    $LastWrite = (get-date).adddays(-7) #over 7 days.
    $Files = Get-Childitem $Folder -Recurse | Where {$_.LastWriteTime -le $LastWrite} #filter files which over 7 days.
    Foreach ($file in $files){
    if ($Exceptions -notcontains $file.fullname){ #if the file is not listed in the exception array.
    Remove-Item $File.FullName -whatif} #use -whatif to test
    I hope this helps.

  • Project Conversion from 11.03 to R12- need help

    Hi All,
    I need some information regarding conversion from 11.03 to R12 along with Capital Project's conversion, do we need to take care Asset Assignment and Assets information at the time of Project Conversion. Iam doing Project and Task conversion different. Is there any good mapping document or Conversion FD, if any body have please send my mail ID. [email protected]
    Thanks for your help.
    Thanks,
    Srini..

    Usually only Open Invoices and Unapplied Receipts are migrated from Old system to New Instance.
    Post Migration Reconciliation shall be tough in that scenario. Reconsider/Rediscuss with Client.
    Migration can be done using APIs or Custom Scripts using Standard Interfaces.
    Hope this is helpful
    Regards,
    Sridhar

  • Since downloading Firefox 4, I am having problems archiving gmail conversations from my inbox view. Also, when I go to enter a new event in google calendar, I now have to click the cursor in the box to type the event (it used to let me just start typing).

    Since downloading Firefox 4, I am having problems archiving gmail conversations from my inbox view (either one or several conversations) as it says "No Conversations Selected" when I have selected one or several. Also, when I go to enter a new event in google calendar, I have to click the cursor in the box to type the event (it used to let me just start typing) or else it flips out and starts jumping to day view or another month. Does anyone know how to fix either of these?

    I have had this problem; but while trying to fix another problem, I reset my preferences for Firefox and it fixed this problem as well. To reset preferences, follow this link: http://support.mozilla.com/en-US/kb/Resetting%20preferences

  • How can I print a text message conversation from my iPhone? Not using screenshots.

    How can I print a text message conversation from my iPhone? Not using screenshots. It's around 500 messages so screenshots is not a option.

    Yes, you can delete from iphone:
    http://manuals.info.apple.com/enUS/iPhone_iOS4_UserGuide.pdf
    It is covered in the manual.
    Page 172:
    "Delete a podcast: In the Podcasts list in iPod, swipe left or right over the podcast, then
    tap Delete. "

Maybe you are looking for

  • ESSO-LM Template for Web App with select tag

    Hi everyone, I am tasked with creating a template for a web application and the desired behaviour is that when logging into the application the language will be selected from <select> list. It seems that the ESSO only allows to choose from the list o

  • Error in firmware cFP 2020 & connection time out error in MAX

    Hi! My cFP 202O status LED is flashing twice - which indicates that there is an error in the firmware (according to the user manual). I've already installed the latest firmware downloaded from the NI website and it says that I'm suppose to update the

  • Email data messages

    I just downloaded and started using Desktop 4.5.  I am now getting up to 50 times a day the following message on my email: This message is used to carry data between the BlackBerry handheld and an associated server. Please do not delete, move or resp

  • What is MDG

    Hi Experts , What is basically MDG ? S\hall anybody explain the difference between Master Data Governance and Master Data Management in general and with respect to SAP MDM and SAP MDG ? Your inputs are highly appreciable . Regards,

  • Flash video loaded into FLV Player choppy

    I just upgraded to Flash 8 tonight, so I'm a little bit of a newbie as to the new FLV Player that's included (so cool though!!!) I was supposed to add a Preloader to a client's file tonight and got nowhere :( The Flash video that's being loaded into