-
Mar 30th, 2011, 01:24 PM
#1
FlatFileItemReader Reading Past EOF
I'm attempting to learn how to use the FlatFileItemReader to read some data exported from my iTunes Library. When it runs, it is reading all of the file data as expected, but it seems to be attempting to read past the last record. It then issues an incorrect token count exception, saying that it was expecting 27 tokens and only found 1.
Here's the configuration for the reader...
<bean id="reader" class="org.springframework.batch.item.file.FlatFil eItemReader">
<property name="resource" value="classpath:AltNation.txt"/>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping .DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer">
<property name="delimiter" value="|"/>
<property name="names" value="Name, Artist, Composer, Album, Grouping, Genre, Size, Time, DiscNumber, DiscCount, TrackNumber, TrackCount, Year,DateModified, DateAdded, BitRate, SampleRate, VolumeAdjustment, Kind, Equalizer, Comments, Plays, LastPlayed, Skips, LastSkipped, MyRating, Location"/>
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping .BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="ITunesItem"/>
</bean>
</property>
</bean>
</property>
</bean>
<bean id="ITunesItem" class="org.springframework.sample.batch.example.IT unesItem" scope="prototype"/>
Do I need an empty row in the file? Some other marker of some kind?
Thanks.
-
Mar 31st, 2011, 12:59 AM
#2
you don't need an extra-line at the end of the file, on the contrary, there mustn't be any extra line. Did you check the input file?
-
Mar 31st, 2011, 07:55 AM
#3
Hi!
perhaps you may want to consider implementing you own record separator policy for the input file. Since we seldom have a direct influence on the file format delivered, it may be an alternative to describe the file specifics in there.
You may want to scan the reference docs chaper 6.6.2 and the interface org.springframework.batch.item.file.separator.Reco rdSeparatorPolicy.
Regards
Werner
-
Mar 31st, 2011, 11:14 AM
#4
Fixed It. Thanks!
So, just a mea culpa. As I mentioned, I noticed that my input file (an exported playlist from iTunes) was shown in the directory listing as...
-rw-r--r--@
Turns out that the "@", which I had not encountered before, indicates additional hidden attributes. In this case it contains information about what class in Mac OS X should handle the file; essentially, it looks like the resource fork.
Once I coped the data to a new file, the problem went away.
Thanks for your quick replies.
-jim
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules