C# 按索引从列表中删除具有相同值的拆分行

C# 按索引从列表中删除具有相同值的拆分行,c#,split,duplicates,line,distinct,C#,Split,Duplicates,Line,Distinct,-从列表中可以看到一个例子9120038560640,出现两次或可能超过两次。 -列表项中存储的行=File.ReadAllLines(filepath.ToList() -每行用分号分隔。 -第二个索引或[1]应与所有行进行比较,并删除找到的匹配项。 363193;9120038560640;7,11;9,99好的,我得到了答案,这是有效的 items=items.Where(x=>x.Split(“;”)[columnIndex]!=”).OrderBy(x=>x.Split(“;”)[c

-从列表中可以看到一个例子9120038560640,出现两次或可能超过两次。
-列表项中存储的行=File.ReadAllLines(filepath.ToList()
-每行用分号分隔。
-第二个索引或[1]应与所有行进行比较,并删除找到的匹配项。


363193;9120038560640;7,11;9,99好的,我得到了答案,这是有效的

items=items.Where(x=>x.Split(“;”)[columnIndex]!=”).OrderBy(x=>x.Split(“;”)[columnIndex]).ToList(); 列表_items=items.ConvertAll(z=>z)//我独立复制

        string[] itemsArr = items.ToArray();
        int countA = 0;
        foreach (string itemArr in itemsArr)
        {
            List<int> groupDuplicates = new List<int>();
            for (int a = countA; a < itemsArr.Count(); a++)
            {
                if (itemArr != itemsArr[a])
                {
                    if (itemArr.Split(';')[columnIndex] == itemsArr[a].Split(';')[columnIndex]) //if matched then add
                    {
                        groupDuplicates.Add(a); // listing index to be remove
                    }

                    else
                        break; //no way to go through the bottom of the list and also to make the performance faster
                }
                countA++;
            }

            if (groupDuplicates.Count() != 0)
            {
                groupDuplicates.Add(groupDuplicates.First() - 1); //I add here the first item in duplicates

                foreach (int m in groupDuplicates)
                {
                    _items.Remove(items.ElementAt(m)); //remove by item not by index
                }
            }
        }
string[]itemsArr=items.ToArray();
int countA=0;
foreach(itemsArr中的字符串itemArr)
{
List groupDuplicates=新列表();
对于(int a=countA;a
这是您遇到的问题还是您只是想让我们帮您解决?CSV到DataTable,按列区分,如果需要,请再次保存到文件中。你的问题也太宽泛了!您好@Abion47这对我来说是一个有点棘手的问题,所以我请求有人能帮助我。您好@mybirthname这是使用excel吗?我已经那样做了。但我需要自动化它。