Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:46:20+00:00 2026-06-17T16:46:20+00:00

I have a CSV file that looks like: Lorem ipsum dolor sit amet ,

  • 0

I have a CSV file that looks like:

Lorem ipsum dolor sit amet , 12:01
consectetuer adipiscing elit, sed , 12:02

etc…

It is quite a large file (approx. 10,000 rows)
I would like to get the total vocabulary size of all the rows of text together. That is, ignoring the second column (the time), lowercasing everything and then counting the number of different words.

Issues:
1) how to separate each word within each row
2) how to lowercase everything and remove non-alphabetical characters.

So far I have the following code:

import csv
with open('/Users/file.csv', 'rb') as file:
    vocabulary = []
    i = 0
    reader = csv.reader(file, delimiter=',')
    for row in reader:
        for word in row:
            if row in vocabulary:
                break
            else:
                vocabulary.append(word)
                i = i +1
print i

Thank you for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:46:21+00:00Added an answer on June 17, 2026 at 4:46 pm

    You have pretty much what you need. One missing point is lowercase-conversion, which can simply be done with word.lower().

    Another thing you’re missing is splitting into words. You should use .split() for this task, which by default splits on every whitespace-character, i.e., spaces, tabs etc.

    One problem you will have is to distinguish between commas within the text and the column-separation comma. Maybe don’t use csv-reader but simply read each line and remove the time, then split it into words.

    import re
    
    with open('/Users/file.csv', 'rb') as file:
        for line in file:
            line = re.sub(" , [0-2][0-9]:[0-5][0-9]", "", line)
            line = re.sub("[,|!|.|?|\"]", "", line)
            words = [w.lower() for w in line.split()]
            for word in words:
                ...
    

    If you want to remove other characters, include them in the second regular expression. If performance matters to you you should compile two regular expressions once before the for loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a csv file that looks like this: TEST 2012-05-01 00:00:00.203 ON 1
So I have a CSV file that looks like this: 12345, Here is some
I have a CSV file from the US Census that looks like this: ZIP5,ZIP4,ZIP9,STATE
I have a csv file that looks something like this (actual file has many
I have data in a CSV file that looks like: 2745,00,8824,02/15/99,-850.00,-144.20,0.00,0.00,0.00,0.00,-994.20,0.00, I'm trying to
I have data stored in a csv file that looks like this: Date,BLOCK,,Wood,Miscellaneous,,Totals,MO Saturday,4055-RU,4055-AR,4091,1139,1158,,100
I have csv file with a line that looks something like this: ,,,,,,,,,, That's
I have a time series(a csv file) data that looks like below. Each observation
I have a csv file that looks like this NumberofNullAsOfDates 0 I would like
I have a csv file that looks like this: 603629,0,ATLV0008,Vendor1,1942.60,11/04/2010,1942.60,9/1-9/30/10,EFT-JP 603627,2,ATLV0008,Vendor1,1242.40,11/04/2010,1242.40,7/1-7/31/10,EFT-JP 600023,0,FLD4V0003,Vendor2,1950.00,06/15/2010,1950.00,6/14/10 Request,EFT-JP 600024,0,FLD4V0003,Vendor2,1800.00,06/15/2010,1800.00,6/14/10

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.