我正在尝试从CSV文件中提取信息,并使其可读并保存在另一个CSV文件中。我尝试使用IFS =',',但某些列的数据中包含“,”。我主要是使用bash脚本来实现这一目标。
Column StudentName has a "," in the data
这是我的代码。直到我进入StudentName列,它才起作用
#!/bin/bash
#This works but it gets confused when StudentName has a comma in it.
OLDIFS=$IFS
IFS=","
while read StudentID StudentNetworkUsername StudentName StudentFirstName StudentMiddleName StudentFamilyName GenderCode StudentDOB StudentEmailAddress InternationalStudentFlag CareerDesc ProgramCode ProgramDesc ProgramResearchFlag SubjectAreaCode SubjectAreaDesc CatalogNumber CourseID CourseDesc StudentCourseUnitsEarned LocationCode CourseGradeCode MarkCourseGradeCode StudentAddressLine1 StudentAddressLine2 StudentAddressLine3 StudentAddressLine4 StudentAddressCityCode StudentAddressStateCode StudentAddressPostcode StudentCountryDesc ClassNumber StudentClassGradeDate StudentClassEnrolAddDate StudentClassEnrolDropDate StudentGroupDesc DeliveryModeCode GPA ProgramPlanCode StudentPreferredPhone StudyPeriod AcademicLoadDesc IntensiveModeFlag ExternalModeCode ExternalModeDesc LanguageCode LanguageDesc PartnerCode PartnerDesc
do
echo $StudentFirstName
done < $1
IFS=$OLDIFS
对于这种情况下应如何忽略IFS,我有些困惑