Title: Does CSV Importer import comments?
Last modified: August 19, 2016

---

# Does CSV Importer import comments?

 *  [sbbdc](https://wordpress.org/support/users/sbbdc/)
 * (@sbbdc)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/)
 * Haven’t used this plugin yet, but would like to know if it can import comments
   along with posts?
 * [http://wordpress.org/extend/plugins/csv-importer/](http://wordpress.org/extend/plugins/csv-importer/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [dvkob](https://wordpress.org/support/users/dvkob/)
 * (@dvkob)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345631)
 * sbbdc: No, currently it cannot.
 *  [knarrff](https://wordpress.org/support/users/knarrff/)
 * (@knarrff)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345706)
 * I just extended the exporter to handle comments as well, to some extend. If there
   is interest I would be happy to share this, in the hope it will be part of a 
   future release of cvs_importer.
 *  [dvkob](https://wordpress.org/support/users/dvkob/)
 * (@dvkob)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345707)
 * knarrff: I would be interested, sure. You can send me a patch by email, which
   you can find in the source.
 *  [knarrff](https://wordpress.org/support/users/knarrff/)
 * (@knarrff)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345708)
 * I have sent you the patch. It is not that big actually, but I am also not 100%
   happy with it. However, it worked for me, so I don’t have a direct reason to 
   improve upon it anymore.
 * The reason why I am not really happy has to do with the way comments have to 
   be specified – but that is inherent to the problem: Comments belong to Posts.
   The only easy way to connect a comment to a post in _one_ csv file I could find
   is to write the comment data on the same line as the post data. Now this has 
   some problems:
    - Data for one comment consists of multiple fields, but multiple comments are
      possible as well. This means that there has to be some comment id in the headers.
      This id doesn’t go into wordpress. It is only there to have the connection
      information in the csv file.
    - The number of comments per post can be quite different from post to post. 
      However, there has to be one header for each possible comment. This means 
      you have to know (or guess) a number equal or greater than the maximum number
      of comments for any given post, and generate all of those headers. This was
      not a big problem for me, as I did do that import once and that number was‘
      only’ 17.
    - Even when a post doesn’t have that maximum number of comments, or not even
      a single comment, the post line has to contain a lot of empty fields, otherwise
      the whole post doesn’t import. That seems to be a limitation of the csv-reader.
      However, that’s also not a big issue because it is easy to add a lot of commas
      to the end of each line in the csv file. There seems to be no problem adding
      more of them than needed.
 *  [knarrff](https://wordpress.org/support/users/knarrff/)
 * (@knarrff)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345709)
 * For illustration, here is the header I used (shortened to a maximum of three 
   comments, but you get the idea…):
 * [Large code excerpt removed by moderator. Per forum rules, please use [the pastebin](http://wordpress.pastebin.com/)
   for all large code excerpts. It works better anyway.]
 *  [dvkob](https://wordpress.org/support/users/dvkob/)
 * (@dvkob)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345711)
 * knarrff: Thank you for the patch. I’ve applied it to version 0.3.1. I modified
   it a bit, so the following no longer holds true:
 * > Even when a post doesn’t have that maximum number of comments, or not even 
   > a single comment, the post line has to contain a lot of empty fields, otherwise
   > the whole post doesn’t import.
 *  [knarrff](https://wordpress.org/support/users/knarrff/)
 * (@knarrff)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345713)
 * Thank you. It’s nice to know own code being used by others.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Does CSV Importer import comments?’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)

 * 7 replies
 * 3 participants
 * Last reply from: [knarrff](https://wordpress.org/support/users/knarrff/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/does-csv-importer-import-comments/#post-1345713)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
