Public Function ReadTS(ByVal TSfile As String) As DataTable Try ' Dim return_DataTable As New DataTable ' Dim cnt As Int16 = 0 Dim col_Index As Integer = 0 Dim row_Index As Integer = 0 Dim fs As New IO.FileStream(TSfile, IO.FileMode.Open) Dim sr As New IO.StreamReader(fs) ' While Not SR.EndOfStream ' cnt += 1 ' Dim line As String = SR.ReadLine ' If cnt > 6 Then' On ne tient compte de la lecture qu'a partir de la 7ème ligne If line.Substring(0, 2) = "TS" Then' Nouvelle colonne ? return_DataTable.Columns.Add(line, GetType(System.String))' Ajout dans la table col_Index += 1 row_Index = 0 Else If col_Index = 1 Then' Nouvelle ligne ? Dim Row As DataRow = return_DataTable.NewRow' On ajoute la ligne à la table Row.Item(col_Index - 1) = line return_DataTable.Rows.Add(Row) Else' Nouvelle valeur de ligne ? return_DataTable.Rows(row_Index).Item(col_Index - 1) = line' On ajoute la valeur à la ligne existante row_Index += 1 End If End If End If End While ' Return return_DataTable ' Catch ex As Exception ' Return Nothing ' End Try ' End Function
faire des mes lignes TS ### un début de colonne
TS 1.58 | TS 2.68 | 52 | 62 | 58 | 15 | 59 | 45 |
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDATASET
OBJTYPE "grid3d"
BEGSCL
ND 8000
NC 8000
NAME "benzene"
TS 1 3.1536e+007
2.15396e-031
4.83953e-030
1.71941e-028
4.12743e-027
6.69154e-026
7.97027e-025
7.46346e-024
5.75921e-023
TS 1 6.3072e+007
2.09474e-011
1.94691e-011
1.81398e-011
1.70581e-011
1.61885e-011
1.52008e-011
1.25477e-011
If col_Index = 1 Then' Nouvelle ligne ? Dim Row As DataRow = return_DataTable.NewRow' On ajoute la ligne à la table Row.Item(col_Index - 1) = line return_DataTable.Rows.Add(Row)
DATASET
OBJTYPE "grid3d"
BEGSCL
ND 8000
NC 8000
NAME "benzene"
TS 1 3.1536e+007
1
1
1
6.69154e-026
7.97027e-025
7.46346e-024
5.75921e-023
TS 1 3.1536e+008
1
1
1
6.69154e-026
7.97027e-025
7.46346e-024
5.75921e-023
TS 1 3.1536e+009
1
1
1
6.69154e-026
7.97027e-025
7.46346e-024
5.75921e-023
TS 1 3.1536e+010
1
1
1
6.69154e-026
7.97027e-025
7.46346e-024
5.75921e-023
Dim line As String = sr.ReadLine
Une exception de première chance de type 'System.ArgumentOutOfRangeException' s'est produite dans mscorlib.dll
If cnt > 6 Then ' On ne tient compte de la lecture qu'a partir de la 7ème ligne If line.Length < 2 Then line = "0" + line End If MsgBox(line.Length.ToString) 'Affiche 2 If line.Substring(0, 2) = "TS" Then ' Nouvelle colonne ? return_DataTable.Columns.Add(line, GetType(System.String)) ' Ajout dans la table col_Index += 1 row_Index = 0 Else...
If line.Length >= 2 AndAlso _ line.Substring(0, 2) = "TS" Then
If line.Substring(0, 2) = "TS" Then
Une exception de première chance de type 'System.OverflowException' s'est produite dans ...
Dim newDataTable As DataTable newDataTable = ReadTS(openDataFileDialog.FileName)
Dim cnt As Int16 = 0
Dim cnt As Integer = 0