{"id":992,"date":"2009-04-14T02:25:35","date_gmt":"2009-04-13T17:25:35","guid":{"rendered":"http:\/\/gigasmegas.com\/?p=992"},"modified":"2009-04-15T04:37:56","modified_gmt":"2009-04-14T19:37:56","slug":"visual-basic-2008-tips-textfieldparser%e3%82%af%e3%83%a9%e3%82%b9%e3%81%a7csv%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf%e3%80%81%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/gigasmegas.com\/?p=992","title":{"rendered":"VB.NET Tips TextFieldParser\u30af\u30e9\u30b9\u3067CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3001\u89e3\u6790"},"content":{"rendered":"<p><a href=\"http:\/\/rokuz.com\/?p=\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/rokuz.com\/wp-content\/uploads\/2009\/04\/snag-0117-400x234.png\" alt=\"TextFieldParser\u30af\u30e9\u30b9\u3067CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\" title=\"TextFieldParser\u30af\u30e9\u30b9\u3067CSV\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\" width=\"400\" height=\"234\" class=\"alignnone size-medium wp-image-993\" srcset=\"https:\/\/gigasmegas.com\/wp-content\/uploads\/2009\/04\/snag-0117-400x234.png 400w, https:\/\/gigasmegas.com\/wp-content\/uploads\/2009\/04\/snag-0117.png 494w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<address>photo by <a href=\"http:\/\/www.flickr.com\/photos\/village9991\/\">village9991<\/a><\/address>\n<p>\u30c7\u30fc\u30bf\u3092\u6271\u3046\u30bd\u30d5\u30c8\u306a\u3089\u3001\u305f\u3044\u3066\u3044\u51fa\u529b\u65b9\u6cd5\u3068\u3057\u3066\u3001\u5bfe\u5fdc\u3057\u3066\u3044\u308bCSV\u5f62\u5f0f\u3068\u547c\u3070\u308c\u308b\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3002<\/p>\n<p>\u5f15\u7528\u7b26\u3068\u533a\u5207\u308a\u6587\u5b57\u3067\u3001\u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\u304c\u7c21\u5358\u306b\u51fa\u529b\u3055\u308c\u3001\u30c7\u30fc\u30bf\u306e\u518d\u5229\u7528\u306b\u306f\u3088\u304f\u4f7f\u7528\u3055\u308c\u307e\u3059\u3088\u306d\u3002<\/p>\n<p>CSV\u5f62\u5f0f\u30d5\u30a1\u30a4\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u304c\u3067\u304d\u308c\u3070\u3001\u4ed6\u30bd\u30d5\u30c8\u3067\u4f5c\u6210\u3057\u305f\u4f4f\u6240\u9332\u306a\u3069\u304c\u518d\u5229\u7528\u3067\u304d\u308b\u53ef\u80fd\u6027\u304c\u5e83\u304c\u308a\u307e\u3059\u3002<\/p>\n<p>\u3072\u3044\u3066\u306f\u3001\u5229\u7528\u30e6\u30fc\u30b6\u306e\u62e1\u5927\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u306e\u3067\u3001\u30a4\u30f3\u30dd\u30fc\u30c8\u3001\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u306f\u5fc5\u9808\u6a5f\u80fd\u3067\u3059\u306d\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u3055\u3066\u3001CSV\u5f62\u5f0f\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3001\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u3059\u308b\u306b\u306f\u3001\u5f15\u7528\u7b26\u3001\u533a\u5207\u308a\u6587\u5b57\u3092\u8a8d\u8b58\u3057\u3066\u3001\u6b63\u3057\u304f\u30c7\u30fc\u30bf\u5217\u3001\u30c7\u30fc\u30bf\u9805\u76ee\u3092\u89e3\u6790\u3001\u5207\u308a\u5206\u3051\u3067\u304d\u308c\u3070\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u666e\u901a\u3001\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u7528\u3057\u3001\u30c7\u30fc\u30bf\u5217\u3054\u3068\u306b\u89e3\u6790\u3057\u3001\u30c7\u30fc\u30bf\u9805\u76ee\u3092\u914d\u5217\u306b\u683c\u7d0d\u3059\u308b\u65b9\u6cd5\u3092\u3068\u3063\u3066\u3044\u307e\u3057\u305f\u304c\u3001.NET Framework2.0\u4ee5\u964d\u304b\u3089\u3001TextFieldParser\u30af\u30e9\u30b9\u306a\u308b\u3082\u306e\u304c\u5c0e\u5165\u3055\u308cCSV\u5f62\u5f0f\u306e\u89e3\u6790\u306a\u3069\u304c\u304a\u624b\u8efd\u306b\u884c\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u30d1\u30fc\u30b9\u51e6\u7406\u304c\u7c21\u5358\u306b\u884c\u3048\u308b\u3068\u3001\u5f8c\u306f\u3001\u751f\u6210\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u66f8\u304d\u3059\u308b\u3060\u3051\u3068\u306a\u308b\u306e\u3067\u3001\u307b\u3093\u3068\u3001\u697d\u30c1\u30f3\u3067\u3059\u306d\uff01<\/p>\n<p>[code=&#8221;vb&#8221;]<\/p>\n<p>    Public Function CSVDataFieldRead(ByVal FileName As String, _<br \/>\n                ByVal Delimiter As String, ByVal encode As Encoding)<br \/>\n        CSVDataFieldRead = False<br \/>\n        Try<br \/>\n            Dim csvRecords As New System.Collections.ArrayList()<br \/>\n            Dim TextFP As New FileIO.TextFieldParser(FileName, encode)<\/p>\n<p>            TextFP.TextFieldType = FileIO.FieldType.Delimited<br \/>\n            TextFP.Delimiters = New String() {Delimiter}<br \/>\n            TextFP.HasFieldsEnclosedInQuotes = True<br \/>\n            TextFP.TrimWhiteSpace = True<\/p>\n<p>            While Not TextFP.EndOfData<br \/>\n                csvRecords.Add(TextFP.ReadFields())<br \/>\n            End While<\/p>\n<p>            Dim i As Integer<br \/>\n            For Each m As String() In csvRecords<br \/>\n                For Each FieldStr As String In m<br \/>\n                    Console.WriteLine(FieldStr)<br \/>\n                    i += 1<br \/>\n                Next<br \/>\n            Next<\/p>\n<p>            TextFP.Close()<\/p>\n<p>        Catch ex As Exception<br \/>\n            Console.WriteLine(ex.Message)<br \/>\n        End Try<br \/>\n        CSVDataFieldRead = True<\/p>\n<p>        Call Style_FlexGridCust(FlexGridDataMap)<\/p>\n<p>    End Function<\/p>\n<p>    Private Sub Button1_Click(ByVal sender As System.Object, _<br \/>\n                ByVal e As System.EventArgs) Handles Button1.Click<br \/>\n        Call CSVDataFieldRead(&#8220;C:test.csv&#8221;, &#8220;,&#8221;, Encoding.GetEncoding(&#8220;Shift_JIS&#8221;))<br \/>\n    End Sub<\/p>\n<p>[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>photo by village9991 \u30c7\u30fc\u30bf\u3092\u6271\u3046\u30bd\u30d5\u30c8\u306a\u3089\u3001\u305f\u3044\u3066\u3044\u51fa\u529b\u65b9\u6cd5\u3068\u3057\u3066\u3001\u5bfe\u5fdc\u3057\u3066\u3044\u308bCSV\u5f62\u5f0f\u3068\u547c\u3070\u308c\u308b\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3002 \u5f15\u7528\u7b26\u3068\u533a\u5207\u308a\u6587\u5b57\u3067\u3001\u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\u304c\u7c21\u5358\u306b\u51fa\u529b\u3055\u308c\u3001\u30c7\u30fc\u30bf\u306e\u518d\u5229\u7528\u306b\u306f\u3088\u304f\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,303,25,32],"tags":[306,272,308,337,336,254,304,307],"class_list":["post-992","post","type-post","status-publish","format-standard","hentry","category-sqlserver","category-vbnet","category-computer","category-database","tag-net","tag-272","tag-basic","tag-csv","tag-textfieldparser","tag-tips","tag-vb","tag-visual"],"_links":{"self":[{"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=992"}],"version-history":[{"count":2,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/992\/revisions"}],"predecessor-version":[{"id":1007,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=\/wp\/v2\/posts\/992\/revisions\/1007"}],"wp:attachment":[{"href":"https:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gigasmegas.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}