Naveen Singh

Naveen Singh

  • NA
  • 10
  • 2.5k

Remove unwanted Text before and after a character in .csv

Jul 30 2014 8:11 AM
Hi Friends i have a .csv file in which there are some unwanted text which i want to remove for extracting the files name only. If anybody is having any idea to solve this please help.

>(Get-Content "D:\Convert\txtdoc\rtbTextBox.csv") |

>Foreach-object {$_ -replace ".*>" -replace "<\.*"} |

>Set-Content "D:\Convert\txtdoc\rtbTextBox.csv"


File is having Text as below:

    <deployment>
  <metadata>
    <title>TEST-2014-08026</title>
    <date>30-05-2014</date>
    <author>Developer</author>
    <svnrevision>svn://10.285.120.144/devmd/Trunk</svnrevision>
  </metadata>
  <csvfiles>
    <csv>
        <file>load\hcl\safetoload\doc_typ\TEST-2014-08026_doc_typ.csv</file>
        <loadCtl>hcl\safetoload\doc_typ\doc_typ.ctl</loadCtl>
        <AffectedTables>
            <table tname="doc_typ"/>
        </AffectedTables>
    </csv>
    <csv>
        <file>load\hcl\safetoload\doc_typ_arg\TEST-2014-08026_doc_typ_arg.csv</file>
        <loadCtl>hcl\safetoload\doc_typ_arg\doc_typ_arg.ctl</loadCtl>
        <AffectedTables>
            <table tname="doc_typ_arg"/>
        </AffectedTables>
    </csv>
    <csv>
        <file>load\hcl\safetoload\doc_lblfmt\TEST-2014-08026_doc_lblfmt.csv</file>
        <loadCtl>hcl\safetoload\doc_lblfmt\doc_lblfmt.ctl</loadCtl>
        <AffectedTables>
            <table tname="doc_lblfmt"/>
        </AffectedTables>
    </csv>

    <csv>
        <file>load\hcl\safetoload\dscmst\TEST-2014-08026_dscmst.csv</file>
        <loadCtl>hcl\safetoload\dscmst\dscmst.ctl</loadCtl>
        <AffectedTables>
            <table tname="dscmst"/>
        </AffectedTables>
    </csv>

    <csv>
        <file>load\hcl\safetoload\lblfmt\TEST-2014-08026_lblfmt.csv</file>
        <loadCtl>hcl\safetoload\lblfmt\lblfmt.ctl</loadCtl>
        <AffectedTables>
            <table tname="lblfmt"/>
        </AffectedTables>
    </csv>
    
  </csvfiles>
  <files>
    <labels>
        <label>
          <directories>
            <dir>labels</dir>
          </directories>
          <labelFiles>
            <labFile>LABEL\1662_ceva_carlbl.POF</labFile>
            <labFile>LABEL\1662_ceva_carlbl.lbl</labFile>
            <labFile>1662_ceva_carlbl.msql</labFile>
          </labelFiles>
        </label>
    </labels>
  </files>
</deployment>
   

I want to save result as For EX :**

TEST-2014-08026_doc_typ.csv
doc_typ.ctl
TEST-2014-08026_doc_typ_arg.csv
doc_typ_arg.ctl
TEST-2014-08026_doc_lblfmt.csv


Answers (7)