Get specific fields from csv file


(King Prakatheesh) #1

i am haing a csv file having 100 fields. i want to parse only 5 fields so i used Ruby filter and framed my conf. Upon executing getting {} in all lines instead of fields

Conf file

input{
file {
path => path_to_file
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
ruby {
code => "
wanted_fields = ['','']
event.to_hash.keys.each { |k|
event.remove(k) unless wanted_fields.include? k
}
"
}
}
output
{
stdout{}
}

Output:

{}
{}
{}
{}
{}

Thanks in advance


(Magnus B├Ąck) #2

I suggest you use the prune filter for this.


(bus) #3

You can parse your CSV with "CSV" filter option and then you can use "remove_field" to remove undesirable fields


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.