Perl parsing text file




















Select personalised content. Create a personalised content profile. Measure ad performance. Select basic ads. Create a personalised ads profile. Select personalised ads. Apply market research to generate audience insights. Measure content performance. Develop and improve products. List of Partners vendors.

You're trying to visit a URL that doesn't currently exist on the web. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.

COuld you please correct it! Answered by d5e5 in a post from 11 Years Ago. The following prints only one group that has the most " -ALY" records if more than one group … Jump to Post. Values are returned in descending numeric order highest to lowest.

Best regards Quy. Dear David The problem is solved. The first is a reasonable solution for simple CSV files, that does not require anything beyond Perl. The second fixes some problems caused by a slightly more complex CSV files. The third is probably the best solution. The price is that these solutions depend on a module from CPAN. Pick the one that matches your needs. In each row there are fields separated with comma. Of course the separator can be any character as long as it is the same in the whole file.

Anyway, the task was to summarize the number in the 3rd column. The algorithm The process should go like this: Read in the file line by line.

For each line, extract the 3rd column. Add the value to a central variable where we accumulate the sum. We have already learned earlier how to read a file line by line so we only need to know how to process each row and how to extract the 3rd column. I cannot use substr easily as the location of the 3rd field is changing. What is fixed is that it is between the 2nd and the 3rd comma.

I could use index 3 times on each row to locate the 2nd and the 3rd comma, and then use substr but Perl has a much easier way for this. Using split split usually gets two parameters. The first is a knife, the second is the string that needs to be cut in pieces.

The knife is actually a regular expression but for now we can stick to simple strings there. The array fields will be filled with 4 values: "Tudor", "Vidor", "10" and "Hapci". You should read the question more carefully. What wrong you find there. I have to remove whole of the sequence of lines: not just the first Your question is not clear to me.

I did not write a question. It really does not matter anyway, nithinpes already posted a working solution to the original question. Sorry, for repetition of same post.. Please ignore this post As its a hassed statement. Any way thanks to every one Hey all, I am done with the complete task..! Attached Files 1. Post Reply.



0コメント

  • 1000 / 1000