我正在尝试读取包含特殊字符和空格的headercolumns的CSV文件。我需要将CSV数据推送到MySQL,当我使用预定义的列名创建表时会抛出语法错误。
我正在使用Apache commons.csv
。我尝试按如下方式提供CSV格式:
CSVFormat format = CSVFormat.MYSQL.withSkipHeaderRecord().withHeader(headerstring).withDelimiter(',').withQuote('"');
headerstring是 -
"auto_videoId", "videoId", "join_key", "eventId", "name", "LocationShelf", "Action", "Interaction", "TablesAvailability", "timeSpent"
不是将其作为单独的列名条目,而是作为一个字符串读取并抛出错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"auto_videoId", "videoId", "join_key", "eventId", "name", "LocationShelf", "Acti' at line 1
P.S- CSV已经有相同的列名但有特殊字符。