約 4,524,248 件
https://w.atwiki.jp/ce00582/pages/5799.html
package sql; import tool.*; import java.io.*; public class pro { int s,datanumber,artistnumber; String[] data=new String[50000]; String[] artist=new String[50000]; String[] dic=new String[50000]; String[] year=new String[50000]; String[] month=new String[50000]; String[] point=new String[50000]; int[] number=new int[50000]; int sx,h; public static void main(String[] args) { pro test=new pro(); } pro(){ readfile sub=new readfile(); sub.makedata("ame.csv","UTF-8"); datanumber=sub.datanumber; data=sub.data; sx=0; for(s=2;s datanumber+1;s++){ String[] x=data[s].split(","); sx=sx+1; artist[sx]=x[0]; year[sx]=x[1]; month[sx]=x[2]; point[sx]=x[3]; } datanumber=sx; System.out.println(datanumber); for(s=1;s datanumber+1;s++){ h=0; for(sx=1;sx artistnumber+1;sx++){ if(artist[s].equals(dic[sx]))h=100; } if(h 50)artistnumber=artistnumber+1; if(h 50)dic[artistnumber]=artist[s]; } for(s=1;s datanumber+1;s++){ for(sx=1;sx artistnumber+1;sx++){ if(artist[s].equals(dic[sx]))number[s]=sx; } } writex("ren.txt"); writeartist("artist.txt"); } void writeartist(String file){ try{ PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); for(s=1;s artistnumber+1;s++){ pw.println(dic[s]); } System.out.println("ファイルに書きこみました。"); pw.close(); } catch(IOException ep){ System.out.println("入出力エラーです。"); } } void writex(String file){ try{ PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); for(s=1;s datanumber+1;s++){ pw.print(number[s]); pw.print(","); pw.print(year[s]); pw.print(","); pw.print(month[s]); pw.print(","); pw.println(point[s]); } System.out.println("ファイルに書きこみました。"); pw.close(); } catch(IOException ep){ System.out.println("入出力エラーです。"); } } }
https://w.atwiki.jp/heppokoact/
@ECHO OFF set HOOKDIR="E \repository\hooks" set TMPDIR="%HOOKDIR%\.svnhook" set SVNLOOKDIR="E \subversion\bin" set REPOS=%1 set TXN=%2 set RET=1 set LOG=%TMPDIR%\%TXN%.log set CHANGED=%TMPDIR%\%TXN%.changed if not exist %TMPDIR% mkdir %TMPDIR% call %SVNLOOKDIR%\svnlook log -t %TXN% %REPOS% %LOG% call %SVNLOOKDIR%\svnlook changed -t %TXN% %REPOS% %CHANGED% cd %HOOKDIR% java -classpath %HOOKDIR% SvnToCsv %LOG% %CHANGED% set RET=%ERRORLEVEL% del %LOG% del %CHANGED% exit %RET% import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * svn logの実行結果からCSVを作成します。 * */ public class SvnToCsv { private String log; private String changed; public static void main(String[] args) { if (args.length != 2) { System.err.println("引数の数が変ですよ。(" + args.length + "個)"); System.exit(1); } int result; try { result = new SvnToCsv(args[0], args[1]).toCsv(); } catch (Exception e) { System.err.print(e.getMessage()); result = 1; } System.exit(result); } public SvnToCsv(String logPath, String changedPath) throws IOException { log = read(logPath); changed = read(changedPath); } public int toCsv() throws IllegalFormatException, IOException { // 特定のディレクトリへの変更をしなければスルー if (!needToCsv()) { return 0; } String bugNo = getFirstGroup(log, "課題管理番号:(\\d+)"); String comment = getFirstGroup(log, "コメント:(.+)"); String[] changedPathes = getChangdPathes(); write(toCsvString(bugNo, comment, changedPathes)); return 0; } private void write(String csv) throws IOException { FileOutputStream out = null; PrintWriter writer = null; try { out = new FileOutputStream(new File("C /release.log"), true); FileChannel channel = out.getChannel(); FileLock lock = getLock(channel); writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out))); writer.print(csv); lock.release(); } finally { if (writer != null) writer.close(); if (out != null) out.close(); } } private FileLock getLock(FileChannel channel) throws IOException { for (int i=0; i 5; i++) { FileLock lock = channel.tryLock(); if (lock == null) { try { Thread.sleep(1000); continue; } catch (InterruptedException e) {} } return lock; } throw new IOException("C /release.logのロックが取得できませんでした。"); } private String toCsvString(String bugNo, String comment, String[] changedPathes) { StringBuilder builder = new StringBuilder(); for (String path changedPathes) { builder.append(bugNo).append(",").append(path).append(",").append(comment).append("\r\n"); } return builder.toString(); } private String[] getChangdPathes() throws IllegalFormatException { String[] changedArray = changed.split("\\r\\n"); String[] changedPathes = new String[changedArray.length]; for (int i=0; i changedArray.length; i++) { String changedElement = changedArray[i]; changedPathes[i] = getFirstGroup(changedElement, ".+/ほげ/(ふが/.+)"); } return changedPathes; } private String getFirstGroup(String target, String regexp) throws IllegalFormatException { Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(target); if (!matcher.find()) { throw new IllegalFormatException("正規表現「" + regexp + "」が見つかりません。\r\n対象:" + target); } return matcher.group(1); } private boolean needToCsv() { Pattern pattern = Pattern.compile("/ほげ/"); return pattern.matcher(changed).find(); } private String read(String path) throws IOException { BufferedReader reader = null; StringBuilder builder = new StringBuilder(); try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(path), "MS932")); while (true) { String line = reader.readLine(); if (line == null) break; builder.append(line).append("\r\n"); } } finally { if (reader != null) reader.close(); } return builder.toString(); } private class IllegalFormatException extends Exception { IllegalFormatException(String message) { super(message); } } }
https://w.atwiki.jp/rubymemo/pages/13.html
標準添付ライブラリ http //doc.okkez.net/static/192/library/csv.html ruby 1.9でインターフェイス変更 require "csv" array_of_array = CSV.read("file.csv") 読み込み array_of_array = CSV.read(path) # ファイルを読み込み array_of_array = CSV.parse(string) # 文字列を読み込み array_of_array = CSV.new(io).read # ioから読み込み array_of_array = CSV.parse(string, col_sep = "\t") # タブ区切りの場合 書き込み CSV.open(path, "w"){|csv| ...} # ファイルに書き込み string = CSV.generate{|csv| ...} # 文字列を生成 csv.puts ["a", "b", "c"] # csvオブジェクトへの行書き込み csv ["a", "b", "c"] # 同上 文字コード array_of_array = CSV.read(path, encoding "utf-8") # utf-8ファイルの読み込み 備考 1.8ではCSV.parse(string) が誤作動する場合があるので注意 (参考)
https://w.atwiki.jp/rubyontube/pages/12.html
CSVに関連するサンプル def openCSV print "ああああああああ" end
https://w.atwiki.jp/satoschi/pages/8173.html
* |Sino-Tibetan languages|Tibeto-Burman languages|Kuki-Chin-Naga languages| 言語類型 現用言語 使用文字 type living language writing system ISO 639-3 【csv】 言語名別称 alternate names Ahmyo Chang Hmyo Settu Settu Hmyo Sungtu 方言名 dialect names 参考文献 references WEB ISO 639-3 Registration Authority - SIL International
https://w.atwiki.jp/erebos/pages/38.html
CSVを扱うクラス public class CSVOperate { #region 変数 private System.Data.DataTable dt = new DataTable(); private System.Data.OleDb.OleDbDataAdapter da = null; private int iRowLength = 0; private int iColLength = 0; #endregion #region プロパティ /// summary /// 行数 /// /summary public int RowLength { set { this.iRowLength = value; } get { return this.iRowLength; } } /// summary /// 列数 /// /summary public int ColLength { set { this.iColLength = value; } get { return this.iColLength; } } #endregion #region コンストラクタ /// summary /// コンストラクタ /// /summary /// param name="csvPath" CSVファイルパス(ヘッダー無しのCSV対象) /param public CSVOperate(string csvPath) { string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; // 作業フォルダをCSVのあるフォルダに設定 if (Directory.Exists(System.IO.Path.GetDirectoryName(csvPath))) System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(csvPath)); //接続 string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @"." + ";Extended Properties=\"text;HDR=NO;FMT=Delimited\""; System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(conString); string commText = "SELECT * FROM [" + System.IO.Path.GetFileName(csvPath) + "]"; this.da = new System.Data.OleDb.OleDbDataAdapter(commText, con); //DataTableに格納する this.da.Fill(this.dt); // 行数を格納 this.iRowLength = dt.Rows.Count; // 列数を格納 this.iColLength = dt.Columns.Count; // 作業フォルダをアプリケーション実行フォルダに戻す System.IO.Directory.SetCurrentDirectory(baseDirectory); } #endregion #region メソッド /// summary /// 指定行列の値を取得する /// /summary /// param name="rowIdx" 行インデクス /param /// param name="colIdx" 列インデクス /param /// returns 指定行列の値 /returns public string getValue(int rowIdx, int colIdx) { if (rowIdx 0 || colIdx 0 || this.iRowLength rowIdx || this.iColLength colIdx) throw new ArgumentException(String.Format("指定されたインデクスは不正です。ROW={0},COL={1}", rowIdx, colIdx)); return dt.Rows[rowIdx][colIdx].ToString(); } #endregion }
https://w.atwiki.jp/mieyanman/pages/22.html
zip2 zip3 [sqlplus_csv] clsDesc.vb Public Class clsDesc Public Property c0Name As String = "" Public Property c1Null As String = "" Public Property c2Type As String = "" End Class clsSelectionRowsMove.vb Public Class clsSelectionRowsMove Dim m_DataGridView As DataGridView = Nothing Dim m_RowsCount As Integer = 0 Dim m_SelectedRowsCount As Integer = 0 Dim m_SelectedRowMin As Integer = 0 Dim m_SelectedRowMax As Integer = 0 Dim m_MoveUpEnabled As Boolean = False Dim m_MoveDownEnabled As Boolean = False Public ReadOnly Property RowsCount() As Integer Get Return m_RowsCount End Get End Property Public ReadOnly Property SelectedRowsCount() As Integer Get Return m_SelectedRowsCount End Get End Property Public ReadOnly Property SelectedRowMin() As Integer Get Return m_SelectedRowMin End Get End Property Public ReadOnly Property SelectedRowMax() As Integer Get Return m_SelectedRowMax End Get End Property Public ReadOnly Property MoveUpEnabled() As Boolean Get Return m_MoveUpEnabled End Get End Property Public ReadOnly Property MoveDownEnabled() As Boolean Get Return m_MoveDownEnabled End Get End Property Public Enum MoveType Top Up Down Bottom End Enum Public Sub New(wp_DataGridView As DataGridView) If wp_DataGridView Is Nothing Then Return End If m_DataGridView = wp_DataGridView m_RowsCount = m_DataGridView.Rows.Count If m_RowsCount 0 Then m_SelectedRowsCount = m_DataGridView.SelectedRows.Count If m_SelectedRowsCount 0 Then Dim w_RowMin As Integer = m_RowsCount Dim w_RowMax As Integer = 0 For i As Integer = m_SelectedRowsCount - 1 To 0 Step -1 If w_RowMin m_DataGridView.SelectedRows(i).Index Then w_RowMin = m_DataGridView.SelectedRows(i).Index End If If w_RowMax m_DataGridView.SelectedRows(i).Index Then w_RowMax = m_DataGridView.SelectedRows(i).Index End If Next m_SelectedRowMin = w_RowMin m_SelectedRowMax = w_RowMax If m_RowsCount 1 Then If m_SelectedRowMin 0 Then m_MoveUpEnabled = True End If If m_SelectedRowMax m_RowsCount - 1 Then m_MoveDownEnabled = True End If End If End If End If End Sub Public Sub SelectionRowsMove(wp_Move As MoveType) If m_DataGridView.SelectedRows.Count = 0 Then Return End If Dim w_SelectionRowList As New List(Of DataGridViewRow) For Each r As DataGridViewRow In m_DataGridView.SelectedRows w_SelectionRowList.Add(r) m_DataGridView.Rows.Remove(r) Next Dim w_Row1 As Integer = 0 Select Case wp_Move Case MoveType.Top w_Row1 = 0 Case MoveType.Up w_Row1 = m_SelectedRowMin - 1 Case MoveType.Down w_Row1 = m_SelectedRowMin + 1 Case MoveType.Bottom w_Row1 = m_DataGridView.Rows.Count Case Else End Select Dim w_Row2 As Integer = w_Row1 + w_SelectionRowList.Count - 1 m_DataGridView.Rows.Insert(w_Row1, w_SelectionRowList.Count) For i As Integer = 0 To w_SelectionRowList.Count - 1 For j As Integer = 0 To m_DataGridView.Columns.Count - 1 m_DataGridView.Rows(w_Row2 - i).Cells(j).Value = w_SelectionRowList(i).Cells(j).Value Next Next m_DataGridView.CurrentCell = m_DataGridView.Rows(w_Row1).Cells(0) For i As Integer = w_Row1 To w_Row2 m_DataGridView.Rows(i).Selected = True Next End Sub End Class frmCsvFile.Designer.vb Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() _ Partial Class frmCsvFile Inherits System.Windows.Forms.Form フォームがコンポーネントの一覧をクリーンアップするために dispose をオーバーライドします。 System.Diagnostics.DebuggerNonUserCode() _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub Windows フォーム デザイナーで必要です。 Private components As System.ComponentModel.IContainer メモ 以下のプロシージャは Windows フォーム デザイナーで必要です。 Windows フォーム デザイナーを使用して変更できます。 コード エディターを使って変更しないでください。 System.Diagnostics.DebuggerStepThrough() _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.TxtConnect = New System.Windows.Forms.TextBox() Me.TxtTableName = New System.Windows.Forms.TextBox() Me.Button1 = New System.Windows.Forms.Button() Me.Label3 = New System.Windows.Forms.Label() Me.TxtWorkFolder = New System.Windows.Forms.TextBox() Me.DataGridView1 = New System.Windows.Forms.DataGridView() Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.Column3 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.TmiOpen = New System.Windows.Forms.ToolStripMenuItem() Me.TmiAdd = New System.Windows.Forms.ToolStripMenuItem() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.Label6 = New System.Windows.Forms.Label() Me.TxtCsvFile = New System.Windows.Forms.TextBox() Me.TxtSqlFile = New System.Windows.Forms.TextBox() Me.TxtBatFile = New System.Windows.Forms.TextBox() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.ChkDelWorkFile = New System.Windows.Forms.CheckBox() Me.DataGridView2 = New System.Windows.Forms.DataGridView() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.DataGridViewTextBoxColumn3 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.ContextMenuStrip2 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.TmiTop = New System.Windows.Forms.ToolStripMenuItem() Me.TmiUp = New System.Windows.Forms.ToolStripMenuItem() Me.TmiDown = New System.Windows.Forms.ToolStripMenuItem() Me.TmiBottom = New System.Windows.Forms.ToolStripMenuItem() Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() Me.ContextMenuStrip1.SuspendLayout() CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).BeginInit() Me.ContextMenuStrip2.SuspendLayout() CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainer1.Panel1.SuspendLayout() Me.SplitContainer1.Panel2.SuspendLayout() Me.SplitContainer1.SuspendLayout() Me.SuspendLayout() Label1 Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(12, 9) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(47, 12) Me.Label1.TabIndex = 0 Me.Label1.Text = "Connect" Label2 Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(12, 35) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(62, 12) Me.Label2.TabIndex = 1 Me.Label2.Text = "TableName" TxtConnect Me.TxtConnect.Location = New System.Drawing.Point(81, 6) Me.TxtConnect.Name = "TxtConnect" Me.TxtConnect.Size = New System.Drawing.Size(100, 19) Me.TxtConnect.TabIndex = 2 TxtTableName Me.TxtTableName.Location = New System.Drawing.Point(81, 31) Me.TxtTableName.Name = "TxtTableName" Me.TxtTableName.Size = New System.Drawing.Size(100, 19) Me.TxtTableName.TabIndex = 3 Button1 Me.Button1.Location = New System.Drawing.Point(435, 2) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 4 Me.Button1.Text = "csv作成" Me.Button1.UseVisualStyleBackColor = True Label3 Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(12, 59) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(62, 12) Me.Label3.TabIndex = 5 Me.Label3.Text = "WorkFolder" TxtWorkFolder Me.TxtWorkFolder.Location = New System.Drawing.Point(81, 56) Me.TxtWorkFolder.Name = "TxtWorkFolder" Me.TxtWorkFolder.Size = New System.Drawing.Size(100, 19) Me.TxtWorkFolder.TabIndex = 6 Me.TxtWorkFolder.Text = "C \Temp\sql" DataGridView1 Me.DataGridView1.AllowUserToAddRows = False Me.DataGridView1.AllowUserToDeleteRows = False Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView1.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2, Me.Column3}) Me.DataGridView1.ContextMenuStrip = Me.ContextMenuStrip1 Me.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill Me.DataGridView1.Location = New System.Drawing.Point(0, 0) Me.DataGridView1.Name = "DataGridView1" Me.DataGridView1.ReadOnly = True Me.DataGridView1.RowTemplate.Height = 21 Me.DataGridView1.Size = New System.Drawing.Size(434, 383) Me.DataGridView1.TabIndex = 7 Column1 Me.Column1.HeaderText = "名前" Me.Column1.Name = "Column1" Me.Column1.ReadOnly = True Column2 Me.Column2.HeaderText = "NULL?" Me.Column2.Name = "Column2" Me.Column2.ReadOnly = True Column3 Me.Column3.HeaderText = "型" Me.Column3.Name = "Column3" Me.Column3.ReadOnly = True ContextMenuStrip1 Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TmiOpen, Me.TmiAdd}) Me.ContextMenuStrip1.Name = "ContextMenuStrip1" Me.ContextMenuStrip1.Size = New System.Drawing.Size(154, 48) TmiOpen Me.TmiOpen.Name = "TmiOpen" Me.TmiOpen.Size = New System.Drawing.Size(153, 22) Me.TmiOpen.Text = "tabファイルを開く" TmiAdd Me.TmiAdd.Name = "TmiAdd" Me.TmiAdd.Size = New System.Drawing.Size(153, 22) Me.TmiAdd.Text = "列追加" Label4 Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(234, 9) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(42, 12) Me.Label4.TabIndex = 8 Me.Label4.Text = "csvFile" Label5 Me.Label5.AutoSize = True Me.Label5.Location = New System.Drawing.Point(234, 35) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(39, 12) Me.Label5.TabIndex = 9 Me.Label5.Text = "sqlFile" Label6 Me.Label6.AutoSize = True Me.Label6.Location = New System.Drawing.Point(234, 59) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(40, 12) Me.Label6.TabIndex = 10 Me.Label6.Text = "batFile" TxtCsvFile Me.TxtCsvFile.Location = New System.Drawing.Point(280, 6) Me.TxtCsvFile.Name = "TxtCsvFile" Me.TxtCsvFile.Size = New System.Drawing.Size(100, 19) Me.TxtCsvFile.TabIndex = 11 TxtSqlFile Me.TxtSqlFile.Location = New System.Drawing.Point(280, 31) Me.TxtSqlFile.Name = "TxtSqlFile" Me.TxtSqlFile.Size = New System.Drawing.Size(100, 19) Me.TxtSqlFile.TabIndex = 12 Me.TxtSqlFile.Text = "csv.sql" TxtBatFile Me.TxtBatFile.Location = New System.Drawing.Point(280, 56) Me.TxtBatFile.Name = "TxtBatFile" Me.TxtBatFile.Size = New System.Drawing.Size(100, 19) Me.TxtBatFile.TabIndex = 13 Me.TxtBatFile.Text = "csv.bat" Button2 Me.Button2.Location = New System.Drawing.Point(435, 27) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(75, 23) Me.Button2.TabIndex = 14 Me.Button2.Text = "csv開く" Me.Button2.UseVisualStyleBackColor = True Button3 Me.Button3.Location = New System.Drawing.Point(435, 52) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(75, 23) Me.Button3.TabIndex = 15 Me.Button3.Text = "フォルダ開く" Me.Button3.UseVisualStyleBackColor = True ChkDelWorkFile Me.ChkDelWorkFile.AutoSize = True Me.ChkDelWorkFile.Checked = True Me.ChkDelWorkFile.CheckState = System.Windows.Forms.CheckState.Checked Me.ChkDelWorkFile.Location = New System.Drawing.Point(551, 5) Me.ChkDelWorkFile.Name = "ChkDelWorkFile" Me.ChkDelWorkFile.Size = New System.Drawing.Size(85, 16) Me.ChkDelWorkFile.TabIndex = 16 Me.ChkDelWorkFile.Text = "DelWorkFile" Me.ChkDelWorkFile.UseVisualStyleBackColor = True DataGridView2 Me.DataGridView2.AllowUserToAddRows = False Me.DataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.DataGridView2.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.DataGridViewTextBoxColumn1, Me.DataGridViewTextBoxColumn3}) Me.DataGridView2.ContextMenuStrip = Me.ContextMenuStrip2 Me.DataGridView2.Dock = System.Windows.Forms.DockStyle.Fill Me.DataGridView2.Location = New System.Drawing.Point(0, 0) Me.DataGridView2.Name = "DataGridView2" Me.DataGridView2.ReadOnly = True Me.DataGridView2.RowTemplate.Height = 21 Me.DataGridView2.Size = New System.Drawing.Size(302, 383) Me.DataGridView2.TabIndex = 17 DataGridViewTextBoxColumn1 Me.DataGridViewTextBoxColumn1.HeaderText = "名前" Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1" Me.DataGridViewTextBoxColumn1.ReadOnly = True DataGridViewTextBoxColumn3 Me.DataGridViewTextBoxColumn3.HeaderText = "型" Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3" Me.DataGridViewTextBoxColumn3.ReadOnly = True ContextMenuStrip2 Me.ContextMenuStrip2.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.TmiTop, Me.TmiUp, Me.TmiDown, Me.TmiBottom}) Me.ContextMenuStrip2.Name = "ContextMenuStrip2" Me.ContextMenuStrip2.Size = New System.Drawing.Size(99, 92) TmiTop Me.TmiTop.Name = "TmiTop" Me.TmiTop.Size = New System.Drawing.Size(98, 22) Me.TmiTop.Text = "最上" TmiUp Me.TmiUp.Name = "TmiUp" Me.TmiUp.Size = New System.Drawing.Size(98, 22) Me.TmiUp.Text = "上へ" TmiDown Me.TmiDown.Name = "TmiDown" Me.TmiDown.Size = New System.Drawing.Size(98, 22) Me.TmiDown.Text = "下へ" TmiBottom Me.TmiBottom.Name = "TmiBottom" Me.TmiBottom.Size = New System.Drawing.Size(98, 22) Me.TmiBottom.Text = "最下" SplitContainer1 Me.SplitContainer1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.SplitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.SplitContainer1.Location = New System.Drawing.Point(14, 81) Me.SplitContainer1.Name = "SplitContainer1" SplitContainer1.Panel1 Me.SplitContainer1.Panel1.Controls.Add(Me.DataGridView1) SplitContainer1.Panel2 Me.SplitContainer1.Panel2.Controls.Add(Me.DataGridView2) Me.SplitContainer1.Size = New System.Drawing.Size(744, 385) Me.SplitContainer1.SplitterDistance = 436 Me.SplitContainer1.TabIndex = 18 frmCsvFile Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(770, 478) Me.Controls.Add(Me.SplitContainer1) Me.Controls.Add(Me.ChkDelWorkFile) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.TxtBatFile) Me.Controls.Add(Me.TxtSqlFile) Me.Controls.Add(Me.TxtCsvFile) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.TxtWorkFolder) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TxtTableName) Me.Controls.Add(Me.TxtConnect) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "frmCsvFile" Me.Text = "tabファイルを基にcsvファイルを作成" CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() Me.ContextMenuStrip1.ResumeLayout(False) CType(Me.DataGridView2, System.ComponentModel.ISupportInitialize).EndInit() Me.ContextMenuStrip2.ResumeLayout(False) Me.SplitContainer1.Panel1.ResumeLayout(False) Me.SplitContainer1.Panel2.ResumeLayout(False) CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).EndInit() Me.SplitContainer1.ResumeLayout(False) Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TxtConnect As System.Windows.Forms.TextBox Friend WithEvents TxtTableName As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents TxtWorkFolder As System.Windows.Forms.TextBox Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column2 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Column3 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TxtCsvFile As System.Windows.Forms.TextBox Friend WithEvents TxtSqlFile As System.Windows.Forms.TextBox Friend WithEvents TxtBatFile As System.Windows.Forms.TextBox Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents ChkDelWorkFile As System.Windows.Forms.CheckBox Friend WithEvents DataGridView2 As System.Windows.Forms.DataGridView Friend WithEvents DataGridViewTextBoxColumn1 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents DataGridViewTextBoxColumn3 As System.Windows.Forms.DataGridViewTextBoxColumn Friend WithEvents ContextMenuStrip1 As System.Windows.Forms.ContextMenuStrip Friend WithEvents TmiOpen As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiAdd As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ContextMenuStrip2 As System.Windows.Forms.ContextMenuStrip Friend WithEvents TmiTop As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiUp As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiDown As System.Windows.Forms.ToolStripMenuItem Friend WithEvents TmiBottom As System.Windows.Forms.ToolStripMenuItem Friend WithEvents SplitContainer1 As System.Windows.Forms.SplitContainer End Class frmCsvFile.vb Imports System.Text.RegularExpressions Public Class frmCsvFile Private Enum me_Col1 c0Name c1Null c2Type End Enum Private Enum me_Col2 c0Name c1Type End Enum Private m_SelectionRowsMove As New clsSelectionRowsMove(Me.DataGridView2) Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.TxtConnect.Text = pf_GetIni("", "CSV", "Connect", "ユーザ名/パスワード@ネットサービス名") Me.TxtTableName.Text = pf_GetIni("", "CSV", "TableName", "DUAL") Me.TxtWorkFolder.Text = pf_GetIni("", "CSV", "WorkFolder", "C \Temp\sql") Me.TxtCsvFile.Text = pf_GetIni("", "CSV", "csvFile", "csv.csv") Me.TxtSqlFile.Text = pf_GetIni("", "CSV", "sqlFile", "csv.sql") Me.TxtBatFile.Text = pf_GetIni("", "CSV", "batFile", "csv.bat") Me.TmiTop.Enabled = False Me.TmiUp.Enabled = False Me.TmiDown.Enabled = False Me.TmiBottom.Enabled = False End Sub Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed Call ps_PutIni("", "CSV", "Connect", Me.TxtConnect.Text) Call ps_PutIni("", "CSV", "TableName", Me.TxtTableName.Text) Call ps_PutIni("", "CSV", "WorkFolder", Me.TxtWorkFolder.Text) Call ps_PutIni("", "CSV", "csvFile", Me.TxtCsvFile.Text) Call ps_PutIni("", "CSV", "sqlFile", Me.TxtSqlFile.Text) Call ps_PutIni("", "CSV", "batFile", Me.TxtBatFile.Text) If Me.ChkDelWorkFile.Checked Then Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_DelFile(w_BatFile) Call ms_DelFile(w_SqlFile) End If End Sub Private Sub DataGridView1_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting If e.ColumnIndex 0 AndAlso e.RowIndex = 0 Then Call e.Paint(e.ClipBounds, DataGridViewPaintParts.All) Dim rect As Rectangle = e.CellBounds Call rect.Inflate(-2, -2) Call TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, rect, e.CellStyle.ForeColor, TextFormatFlags.Right Or TextFormatFlags.VerticalCenter) e.Handled = True End If End Sub Private Sub DataGridView2_CellPainting(sender As Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView2.CellPainting If e.ColumnIndex 0 AndAlso e.RowIndex = 0 Then Call e.Paint(e.ClipBounds, DataGridViewPaintParts.All) Dim rect As Rectangle = e.CellBounds Call rect.Inflate(-2, -2) Call TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, rect, e.CellStyle.ForeColor, TextFormatFlags.Right Or TextFormatFlags.VerticalCenter) e.Handled = True End If End Sub Private Sub DataGridView2_SelectionChanged(sender As Object, e As System.EventArgs) Handles DataGridView2.SelectionChanged m_SelectionRowsMove = New clsSelectionRowsMove(Me.DataGridView2) If Me.TmiUp.Enabled m_SelectionRowsMove.MoveUpEnabled Then Me.TmiUp.Enabled = m_SelectionRowsMove.MoveUpEnabled Me.TmiTop.Enabled = m_SelectionRowsMove.MoveUpEnabled End If If Me.TmiDown.Enabled m_SelectionRowsMove.MoveDownEnabled Then Me.TmiDown.Enabled = m_SelectionRowsMove.MoveDownEnabled Me.TmiBottom.Enabled = m_SelectionRowsMove.MoveDownEnabled End If End Sub Private Sub TsbTop_Click(sender As System.Object, e As System.EventArgs) Handles TmiTop.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Top) End Sub Private Sub TsbUp_Click(sender As System.Object, e As System.EventArgs) Handles TmiUp.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Up) End Sub Private Sub TsbDown_Click(sender As System.Object, e As System.EventArgs) Handles TmiDown.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Down) End Sub Private Sub TsbBottom_Click(sender As System.Object, e As System.EventArgs) Handles TmiBottom.Click Call m_SelectionRowsMove.SelectionRowsMove(clsSelectionRowsMove.MoveType.Bottom) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If Me.DataGridView1.Rows.Count = 0 Then MsgBox("tabファイルを開いてください。", MsgBoxStyle.SystemModal) Return End If If Me.DataGridView2.Rows.Count = 0 Then MsgBox("列追加してください。", MsgBoxStyle.SystemModal) Return End If Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_CsvFile As String = String.Format("{0}\{1}.csv", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Dim w_TableName As String = Me.TxtTableName.Text.ToUpper Dim w_CsvSql As String = mf_GetCsvSql(w_CsvFile, w_TableName, Me.TxtConnect.Text) Dim w_SqlFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtSqlFile.Text) Call ms_StreamWriter(w_SqlFile, w_CsvSql) Dim w_BatCommand As String = String.Format("SQLPLUS {0} @{1}", Me.TxtConnect.Text, w_SqlFile) Dim w_BatFile As String = String.Format("{0}\{1}", Me.TxtWorkFolder.Text, Me.TxtBatFile.Text) Call ms_StreamWriter(w_BatFile, w_BatCommand) Call ms_StartProcessWaitForExit(w_BatFile) Select Case MsgBox("csvファイルを開きますか。", MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.SystemModal, "確認") Case MsgBoxResult.Yes Call ms_StartProcess(w_CsvFile) Case Else End Select End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_CsvFile As String = String.Format("{0}\{1}.csv", Me.TxtWorkFolder.Text, Me.TxtTableName.Text) Call ms_StartProcess(w_CsvFile) End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Dim w_WorkFolder As String = Me.TxtWorkFolder.Text Call ms_StartProcess(w_WorkFolder) End Sub Private Sub TmiOpen_Click(sender As System.Object, e As System.EventArgs) Handles TmiOpen.Click Dim w_tabFile As String = mf_FileOpenDialog() If w_tabFile = "" Then Return End If Me.TxtTableName.Text = System.IO.Path.GetFileNameWithoutExtension(w_tabFile) Me.TxtCsvFile.Text = String.Format("{0}.csv", Me.TxtTableName.Text) Dim w_FileText As String = mf_GetFileText(w_tabFile) Dim w_DescList As List(Of clsDesc) = mf_FileTextToDescList(w_FileText) Me.DataGridView1.Rows.Clear() If w_DescList.Count 0 Then Me.DataGridView1.Rows.Add(w_DescList.Count) For i As Integer = 0 To w_DescList.Count - 1 Me.DataGridView1.Rows(i).Cells(me_Col1.c0Name).Value = w_DescList(i).c0Name Me.DataGridView1.Rows(i).Cells(me_Col1.c1Null).Value = w_DescList(i).c1Null Me.DataGridView1.Rows(i).Cells(me_Col1.c2Type).Value = w_DescList(i).c2Type Next Me.DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells) End If End Sub Private Sub TmiAdd_Click(sender As System.Object, e As System.EventArgs) Handles TmiAdd.Click Dim w_ColumnList As List(Of clsDesc) = mf_GetSelectionColumns() Call ms_AddQuery(w_ColumnList) End Sub Private Function mf_GetCsvSql(wp_TxtFile As String, wp_TableName As String, wp_Connect As String) As String Dim sb As New sb() sb.Add("connect {0}", wp_Connect) sb.Add("set echo off") sb.Add("set heading off") sb.Add("set pagesize 0") sb.Add("set feedback off") sb.Add("set linesize 32767") sb.Add("set trimspool on") sb.Add("spool {0}", wp_TxtFile) sb.Add("SELECT ""列番"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", i + 1) Next sb.Add(" AS 列番") sb.Add("FROM DUAL;") sb.Add("SELECT ""列型"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c1Type).Value)) Next sb.Add(" AS 列型") sb.Add("FROM DUAL;") sb.Add("SELECT ""列名"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 sb.Add(" || ,""{0}"" ", mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c0Name).Value)) Next sb.Add(" AS 列名") sb.Add("FROM DUAL;") sb.Add("SELECT ""明細"" ") For i As Integer = 0 To Me.DataGridView2.Rows.Count - 1 Dim w_c0Name As String = mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c0Name).Value) Dim w_c1Type As String = mf_ObjectToString(Me.DataGridView2.Rows(i).Cells(me_Col2.c1Type).Value) Select Case True Case w_c1Type Like "NUMBER*" w_c0Name = String.Format(" || ,"" || TO_CHAR({0}) || "" ", w_c0Name) Case w_c1Type Like "DATE*" w_c0Name = String.Format(" || ,"" || TO_CHAR({0}, YYYY/MM/DD HH24 MI SS ) || "" ", w_c0Name) Case Else w_c0Name = String.Format(" || ,"" || {0} || "" ", w_c0Name) End Select sb.Add("{0}", w_c0Name) Next sb.Add(" AS 明細") sb.Add("FROM {0};", wp_TableName) sb.Add("spool off") sb.Add("set linesize 80") sb.Add("clear") sb.Add("exit") Return sb.ToString End Function Private Sub ms_StreamWriter(wp_File As String, wp_Text As String) Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sw As New System.IO.StreamWriter(wp_File, False, enc) sw.Write(wp_Text) sw.Close() End Sub Private Sub ms_StartProcessWaitForExit(wp_BatFile As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_BatFile) p.WaitForExit() p.Close() p.Dispose() End Sub Private Sub ms_StartProcess(wp_File As String) Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start(wp_File) End Sub Private Function mf_GetFileText(wp_TxtFile As String) As String Dim ret As String = "" Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("shift_jis") Dim sr As New System.IO.StreamReader(wp_TxtFile, enc) ret = sr.ReadToEnd() sr.Close() Return ret End Function Private Function mf_FileTextToDescList(wp_FileText As String) As List(Of clsDesc) Dim ret As New List(Of clsDesc) Dim a1 As String() = Split(wp_FileText, vbCrLf, -1, CompareMethod.Text) For i As Integer = 0 To a1.Count - 1 Dim a2 As String() = Split(a1(i), vbTab, -1, CompareMethod.Text) Select Case a2.Count Case 3 Dim w_Desc As New clsDesc() w_Desc.c0Name = a2(0) w_Desc.c1Null = a2(1) w_Desc.c2Type = a2(2) ret.Add(w_Desc) Case Else End Select Next Return ret End Function Private Function mf_ObjectToString(wp_Object As Object) As String Dim ret As String = "" If Not wp_Object Is Nothing Then ret = wp_Object.ToString End If Return ret End Function Private Sub ms_DelFile(wp_File As String) System.IO.File.Delete(wp_File) End Sub Private Function mf_FileOpenDialog() As String Dim ret As String = "" Dim d As New OpenFileDialog() d.FileName = "" d.InitialDirectory = Me.TxtWorkFolder.Text d.Filter = "tabファイル(*.tab)|*.tab|すべてのファイル(*.*)|*.*" d.FilterIndex = 1 d.Title = "開くファイルを選択してください" d.RestoreDirectory = True If d.ShowDialog() = DialogResult.OK Then ret = d.FileName End If Return ret End Function Private Function mf_GetSelectionColumns() As List(Of clsDesc) Dim ret As New List(Of clsDesc) For Each r As DataGridViewRow In Me.DataGridView1.SelectedRows Dim w As New clsDesc() w.c0Name = mf_ObjectToString(r.Cells(me_Col1.c0Name).Value) w.c1Null = mf_ObjectToString(r.Cells(me_Col1.c1Null).Value) w.c2Type = mf_ObjectToString(r.Cells(me_Col1.c2Type).Value) ret.Add(w) r.Selected = False Next Return ret End Function Private Sub ms_AddQuery(wp_ColumnList As List(Of clsDesc)) If wp_ColumnList.Count = 0 Then Return End If For Each r As DataGridViewRow In Me.DataGridView2.Rows If r.Selected Then r.Selected = False End If Next Me.DataGridView2.Rows.Add(wp_ColumnList.Count) For i As Integer = 0 To wp_ColumnList.Count - 1 Dim w_Row As Integer = Me.DataGridView2.Rows.Count - i - 1 Me.DataGridView2.Rows(w_Row).Cells(me_Col2.c0Name).Value = wp_ColumnList(i).c0Name Me.DataGridView2.Rows(w_Row).Cells(me_Col2.c1Type).Value = wp_ColumnList(i).c2Type Me.DataGridView2.Rows(w_Row).Selected = True Next Me.DataGridView2.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells) Me.DataGridView2.Focus() End Sub End Class mdlInit.vb Imports System.Runtime.InteropServices Module mdlInit DllImport("KERNEL32.DLL", CharSet =CharSet.Auto) _ Public Function GetPrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As System.Text.StringBuilder, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer End Function DllImport("KERNEL32.DLL") _ Public Function WritePrivateProfileString( _ ByVal lpAppName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer End Function Public Function pf_GetIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_Default As String) As String Dim ret As String = wp_Default Dim sb As New System.Text.StringBuilder sb.Capacity = 256 Dim i As Integer = GetPrivateProfileString(wp_section, wp_key, wp_Default, sb, sb.Capacity, mf_path(wp_path)) ret = sb.ToString Return ret End Function Public Sub ps_PutIni(ByVal wp_path As String, ByVal wp_section As String, ByVal wp_key As String, ByVal wp_value As String) Dim i As Integer = WritePrivateProfileString(wp_section, wp_key, wp_value, mf_path(wp_path)) End Sub Private Function mf_path(ByVal wp_path As String) As String Dim ret As String = wp_path If ret = "" Then Dim w_path As String = Application.StartupPath If w_path.EndsWith("\") = False Then w_path = w_path "\" End If ret = String.Format("{0}{1}.ini", w_path, My.Application.Info.AssemblyName) End If Return ret End Function End Module sb.vb Public Class sb Private m_sb As System.Text.StringBuilder Public Sub New() m_sb = New System.Text.StringBuilder() End Sub Public Overrides Function ToString() As String Return m_sb.ToString() End Function Public Function Add(ByVal wp_String As String, ByVal ParamArray wp_Args() As Object) m_sb.AppendFormat(wp_String, wp_Args) m_sb.Append(ControlChars.CrLf) Return m_sb End Function Public Function ToStringRemoveLastCrLf() As String Dim ret As String = m_sb.ToString If ret.Length = vbCrLf.Length Then Dim i As Integer = ret.Length - vbCrLf.Length Dim w As String = ret.Substring(i) If w = vbCrLf Then ret = ret.Substring(0, i) End If End If Return ret End Function Public Sub cb() Clipboard.SetText(m_sb.ToString()) End Sub End Class
https://w.atwiki.jp/rupt/pages/188.html
CSVビュワー ../ ソフトウェア名 CSVビュワー 現Version 1.4 作者(敬称略) 小田桐康弘 配布元 転載中 転載所 ソフトウェア形態 フリーウェア ソース 公開/C 紹介 CSV形式に対応したビューア。検索・抽出・ソートと一通りの閲覧性能を持つ。 CSVというのは金銭管理ソフト等さまざまな用途に使われている一般形式。 ","(コンマ)で区切るだけで簡単に作ることができる(知っているとは思うが) 情報管理のためPCで使っている人も多いのではないだろうから、 それらの資産をRuputerで活用するならば、このアプリはきっと必要となるだろう。 (スクリーンショット情報) 全 RuputerPRO + 画面キャプチャ(rupcaptu) ver1.00
https://w.atwiki.jp/atachi/pages/67.html
CodeProjectで公開されている有名なCSVパーサライブラリ「A Fast CSV Reader」です。 このライブラリはCSV形式の文字列をパースしながらstring型として読み込み専用のライブラリです。 使用方法 CSVファイルからはStreamを使用します。 IDisposableを実装しているのでusing構文を使用します。 const string file = @"c \data.csv"; using(CsvReader csvr = new CsvReader(new StreamReader(file),true) ) { int fieldNum = csvr.FieldCount; string[] headers = csvr.GetFieldHeaders(); while(csvr.ReadNextRecord()) { for(int i=0;i fieldNum;i++) { Console.WriteLine(csvr[i]); } } }
https://w.atwiki.jp/karino2/pages/46.html
WebTobin向けに経済統計を集めてcsvとして公開しています。 https //docs.google.com/spreadsheet/pub?key=0AnKwf3jHs-oIdEE4YnJ3dERMclRqazV0ZjJuN0k0UWc single=true gid=0 output=html 現時点ではタイトル以外は数値のみ対応していて、欠損値は...で表します。 文字列は必要になったら足します。 ここにあるurlを使って、例えば df - read.csv("https //docs.google.com/spreadsheet/pub?key=0AnKwf3jHs-oIdGVESWc4OGs2cVJxYVFLaTFZNHhOLVE single=true gid=0 output=csv") などとすると実質GDPのデータフレームが取れます。 人口統計 公開手順 主に以下のサイトの手順に従っています。 http //blog.revolutionanalytics.com/2009/09/how-to-use-a-google-spreadsheet-as-data-in-r.html google spreadsheetで適当にデータを整形する File- Webに公開 ドキュメント全体をSheet1に ウェブページをcsvに 生成されるURLをコピペ 以前のやり方(そのうち消す事) File- Share- Sheet 1を選び、Start Publishを押す 下のWeb PageをCSVに変更 URLをコピペして公開 最近の更新 2012/07/09 授業者規模別非農林業雇用者数 追加。 2012/07/08 実質GDPを速報値に変更。誤っていたTable Of Contentsを更新。 CPIを暦年ではなく年度別に変更(GDPとあってる方が使いやすいので) 名目GDPを追加(検算の為) 17年基準の実質GDPを追加(最新データが欲しい場合はこちら。接続注意) 人口統計に2010年分を追加。 自営業者の数を調べる為に地位別就業者数を追加。