【问题标题】:Google Docs Export CSV with double quotes带双引号的 Google Docs 导出 CSV
【发布时间】:2011-09-01 15:32:15
【问题描述】:

我有一个需要导出的 Google 电子表格,并且每个字段都包含在双引号“字段”中,但目前它没有这样做。

有没有一种简单的方法来实现这一点而无需手动编辑数百行?

最大

【问题讨论】:

  • CSV 仅在值包含逗号时要求将值括在引号中。为什么需要用引号括起来的所有值?您正在编写自己的 CSV 解析器吗?
  • ruby 似乎不遵守这里的规则。

标签: excel csv google-docs


【解决方案1】:

您也可以使用这样的适当宏从 excel 中使用:

Sub QuoteCommaExport()

   ' Dimension all variables.

   Dim DestFile As String

   Dim FileNum As Integer

   Dim ColumnCount As Integer

   Dim RowCount As Integer



   ' Prompt user for destination file name.

   DestFile = InputBox("Enter the destination filename" & Chr(10) & "(with complete path):", "Quote-Comma Exporter")



   ' Obtain next free file handle number.

   FileNum = FreeFile()



   ' Turn error checking off.

   On Error Resume Next



   ' Attempt to open destination file for output.

   Open DestFile For Output As #FileNum



   ' If an error occurs report it and end.

   If Err <> 0 Then

      MsgBox "Cannot open filename " & DestFile

      End

   End If



   ' Turn error checking on.

   On Error GoTo 0



   ' Loop for each row in selection.

   For RowCount = 1 To Selection.Rows.Count



      ' Loop for each column in selection.

      For ColumnCount = 1 To Selection.Columns.Count



         ' Write current cell's text to file with quotation marks.

         Print #FileNum, """" & Selection.Cells(RowCount, ColumnCount).Text & """";



         ' Check if cell is in last column.

         If ColumnCount = Selection.Columns.Count Then

            ' If so, then write a blank line.

            Print #FileNum,

         Else

            ' Otherwise, write a comma.

            Print #FileNum, ";";

         End If

      ' Start next iteration of ColumnCount loop.

      Next ColumnCount

   ' Start next iteration of RowCount loop.

   Next RowCount



   ' Close destination file.

   Close #FileNum

End Sub

【讨论】:

    【解决方案2】:

    我发现您可以通过使用 Open Office 来实现这一点。您可以根据它们定义自己的分隔符和周围的字符。

    当保存/导出为 CSV 时,选中定义我自己的字符的框。

    【讨论】:

      猜你喜欢
      • 2021-10-30
      • 1970-01-01
      • 2017-01-11
      • 1970-01-01
      • 2020-12-28
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 2021-09-30
      相关资源
      最近更新 更多