I've been trying to read a text file university_towns.txt using read_csv, but as shown in the screenshot, on parsing the file using the regex delimiter as shown in the code below , I get an error of :
ParserError: Expected 2 fields in line 89, saw 3. Error could possibly be due to quotes being ignored when a multi-char delimiter is used.
Is there any way to fix this, it seems only the double quotes are at fault at one place , also kindly explain why this is happening? I also tried to use the quotechar argument, but didn't understand how to use it.
My code for reading the file is as below:
university_towns = pd.read_csv('university_towns.txt', sep= "\s\(", engine='python', header=None)
university_towns.txt file image
Annville (Lebanon Valley College)[2]
Bethlehem (Lehigh University, Moravian College)
Bloomsburg (Bloomsburg University of Pennsylvania)[2]
Bradford (University of Pittsburgh at Bradford)
California (California University of Pennsylvania)[2]
Carlisle (Dickinson College)
Cecil B. Moore, Philadelphia, also known as "Templetown" (Temple University)
Clarion (Clarion University of Pennsylvania)[2]
Collegeville (Ursinus College)
Cresson (Mount Aloysius College)[2]
East Stroudsburg (East Stroudsburg University of Pennsylvania)[2]
Edinboro (Edinboro University of Pennsylvania)[2]
Erie (Gannon University, Mercyhurst College, Penn State Erie)
Gettysburg (Gettysburg College)[2]
Greensburg (Seton Hill University, University of Pittsburgh at Greensburg)
Grove City (Grove City College)[2]
Huntingdon (Juniata College)[2]
Indiana (Indiana University of Pennsylvania)[2]
Johnstown (University of Pittsburgh at Johnstown)
Kutztown (Kutztown University of Pennsylvania)[2]
Lancaster (Franklin & Marshall)
Carrollton (University of West Georgia)[2]*Dahlonega (North Georgia College & State University)[2]
Above I've pasted some of the lines for the text file. Also, the last line is line 89.