ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[ µo°Ý ] ­×§ï vba ¥uŪ¨ú csv ³¡¤ÀÄæ¦ì

[ µo°Ý ] ­×§ï vba ¥uŪ¨ú csv ³¡¤ÀÄæ¦ì

¥H¤U¬O±qºô¤W§ìªº ¤@¬q¥N½XŪ¨úcsv¤å¥ó
csv¤å¥ó¬O±qyahoo finance §äªº¨ººØ®æ¦¡
¦ý¬O¥H¤Uªº¥N½X·|§â¥þ³¡Äæ¦ì»P¸ê®ÆŪ¶i°}¦C¤º

§Æ±æ¯à§ï¦¨¥H¤U¤è¦¡

1.¥u§â date  ¤é´ÁÄæ¦ìŪ¤J°}¦C
2.Ū¨ú date¸ê®Æ«á¡A¥ýÂà´«®æ¦¡¦A¦s¤J°}¦C (­ì©l®æ¦¡¬° 2016-07-27 §Æ±æ¯àÅܦ¨ 2016/07/28)

½Ð±Ð°ª¤â¦p¦ó­×§ï ÁÂÁÂ

Sub cmdGo_Click()

Dim file_name As String
Dim fnum As Integer
Dim whole_file As String
Dim lines As Variant
Dim one_line As Variant
Dim num_rows As Long
Dim num_cols As Long
Dim the_array() As String
Dim R As Long
Dim C As Long

    file_name = ThisWorkbook.Path
   
    If Right$(file_name, 1) <> "\" Then file_name = _
        file_name & "\"
    file_name = file_name & "test.csv"
    ' Load the file.
    fnum = FreeFile
    Open file_name For Input As fnum
    whole_file = Input$(LOF(fnum), #fnum)
    Close fnum

    ' Break the file into lines.
    lines = Split(whole_file, vbCrLf)

    ' Dimension the array.
    num_rows = UBound(lines)
    one_line = Split(lines(0), ",")
    num_cols = UBound(one_line)
    ReDim the_array(num_rows, num_cols)
   

    ' Copy the data into the array.
   
    For R = 0 To num_rows
        If Len(lines(R)) > 0 Then
            one_line = Split(lines(R), ",")
            For C = 0 To num_cols
            the_array(R, C) = one_line(C)
            Next C
        End If
    Next R

    ' Prove we have the data loaded.
    For R = 0 To num_rows
        For C = 0 To num_cols
            MsgBox the_array(R, C) & "|"
            
        Next C
        Debug.Print
    Next R
    Debug.Print "======="
      End Sub

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2016/8/12 07:52): ªþÀɧtcsv ¬Ý¬Ý

¦^´_ 1# yurckr

¦Û°Ý¦Ûµª,¤w¸gµo²{¸ê®Æ±Æ¦Cªº³W«ß¡A¥Î°}¦C¨ú¥X¤é´Á¦C
¦ý¤S¦³°ÝÃD¡A
1.csv ¦p¦ó±oª¾¤é´Á¦³´Xµ§¸ê®Æ?
2.¦p¦ó§ä¥X csv ¤º ³Ì¤p¤é´Á¬°¦ó?

TOP

        ÀR«ä¦Û¦b : ¦Û¤v®`¦Û¤v¡A²ö¹L©ó¶ÃµoµÊ®ð¡C
ªð¦^¦Cªí ¤W¤@¥DÃD