在CSV中选择特定列并插入SQL表

编程入门 行业动态 更新时间:2024-10-27 20:32:54
本文介绍了在CSV中选择特定列并插入SQL表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有一个包含大量列和行的CSV文件(TAB分隔)。 例如: ABCDEFGHILMNO 1 2 3 4 5 6 7 8 9 0 1 2 3 我想只选择特定的列,比如CH L. 从CHL栏中获取结果后,我想要使用INSERT语句将数据放入SQL表。 我该怎么办? Best问候

Hi everyone, I have a CSV file (TAB delimited) with lot of columns and rows. For example: A B C D E F G H I L M N O 1 2 3 4 5 6 7 8 9 0 1 2 3 I wanto to select only specific columns, like C H L. After obtaining the results from the columns C H L , I wanto to put data into a SQL table using INSERT statment. How can i do it ? Best Regards

推荐答案

写一个 CSV 解析器或从网上获取一个(例如参见代码项目文章 CSV分析程序(C#) [ ^ ]),抓取请求的数据然后插入他们进入数据库(你可能会发现只有 Google播放 [ ^ ]。 Write a CSV parser or get one from the web (see for instance this Code Project article CSV Parser (C#)[^]), grab the requested data and then insert them into the database (you may find man y tutorials available just Googling for[^]).

您可以将CSV导入数据集,如使用OleDb导入文本文件(选项卡,CSV,自定义) [ ^ ]。这样您就可以非常轻松地提取特定列。 You can import the CSV into a dataset as described in Using OleDb to Import Text Files (tab, CSV, custom)[^]. This will allow you to extract specific columns quite easily.

更多推荐

在CSV中选择特定列并插入SQL表

本文发布于:2023-11-22 09:07:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CSV   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!