Parse comma separated file
Javascript Program to Check if a string can be obtained by rotating another string 2 places. Python3 Program to Check if a string can be obtained by rotating another string 2 places. String slicing in Python to check if a string can become empty by recursive deletion. Lexicographically smallest string whose hamming distance from given string is exactly K. Article Contributed By :. Easy Normal Medium Hard Expert.
Writing code in comment? Please use ide. Connect and share knowledge within a single location that is structured and easy to search. How do I do that? I am a beginner in python. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Reading comma separated values from text file in python Ask Question.
Asked 8 years, 1 month ago. Active 2 years, 1 month ago. Viewed 9k times. I have a text file consisting of records like fname,lname,subj1,marks1,subj2,marks2,subj3,marks3. Please help When I used split, i got an error saying TypeError: Can't convert 'type' object to str implicitly. Aswin Murugesh 10k 10 10 gold badges 36 36 silver badges 68 68 bronze badges. Yes, he was lucky to find one of those. Usually those things sell out in no time. Do Until objFile.
Write strContents. As RP noted, each line in this file is made up of several different fields. We need to look at the second item in each line e. Coincidentally enough, we next create an instance of the Scripting. Why would we do that? We do that because this gives us an array with the following items:. Is that worth having? You bet it is; after all, each item in the array corresponds quite nicely with the individual fields in our line of text.
As we noted earlier, we need to know if the second field in this line of text has the word Everyone in it. Well, now we have a very easy way to check for that:. Hence the value 1 in arrFields 1. If the target word is not found in arrFields 1 then we simply loop around and repeat the process with the next line in the text file. If the target word is found, then we execute this line of code:.
And yes, we specified 5 as the index number for a very good reason: the sixth item in an array will always have an index number of 5.
0コメント