user1390517
user1390517

Reputation: 249

How To extract the values from csv file in ant?

Washington
New York
New Delhi
India
United States Of America

In ant I want to extract all the values as separate values like washington, new, delhi, india, united, states, of, america. Altough I am able to extract them line wise as

<loadfile property="message" srcFile="../Ant_Scripts/Name.csv"/>
<target name="init">
<for list="${message}" delimiter="${line.separator}" param = "val">
<echo message=${val}/>

but I am not able to extract them as individual units that is once I got New Delhi or New York I should be able to get New and Delhi seprately also.


can you please post your ant script – Satya

    <loadfile property="message" srcFile="../Ant_Scripts/Name.csv"/>
    <target name="init">
         <for list="${message}" delimiter="${line.separator}" param = "val">
              <sequential>
                   <echo>$val</echo>
              </sequential>
         </for>
    </target>
</project>

This code will print all the names line by line, but after this I want to break those lines on the basis of space.

Upvotes: 1

Views: 3740

Answers (1)

HX_unbanned
HX_unbanned

Reputation: 597

There is one fundamental error:

http://dailyraaga.wordpress.com/2010/12/21/ant-for-loop/

  • you have to access the CSV element with @{param}, no ${param}. This loop uses attributes, not properties ;)

There is also one task you might find handy for your line seperation needs:

Upvotes: 1

Related Questions