Answers.Body: <p>Your interpretation of why you're getting duplicate columns when looping your  your table field is wrong.</p>
  
  <p>Each column <em>is always</em> accessible via a automatically generated column handle (<code>col1</code>, <code>col2</code>, etc.), so that's not old and left over column names you're seeing there.</p>
  
  <p>If you define custom handles in the Table field's settings, the cells' data will  be available via those properties as well, so you can then access the value via both <code>row.price</code> and <code>row.col1</code>. This feature is designed with direct access of columns / cells in mind, but gets in the way when looping through a row's cells. </p>
  
  <p>But Craft doesn't force you to define custom handles, so you can simply remove them in your field's settings and your "old data" will be removed.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-29T06:07:21.343Z
Answers.LastActivityDate: 2015-07-29T06:07:21.343Z
Answers.UserDisplayName: carlcs
Body: <p>I have some tables in a matrix field and when I created the columns, originally I named them Col 1, Col 2, etc. That made sense to me but later I decided that since the client will be entering data, it'd make more sense to name them Column 1, Column 2, etc. </p>
  
  <p>I renamed them but that was after I'd entered a bunch of content. So now in the Craft admin, I only see the new names, but when I loop through the entries in the table rows, all of the old entries are there as well. </p>
  
  <p>Is there a way to purge that old data? I want to give the client to enter in the number of a column so you can add a highlight class to it. Right now, as I loop through the entries in those rows, it hits both old and new content and you can't get a dependable count.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-22T16:22:28.020Z
Comments.Text: Sounds like you need to get into the database and do this manually.
Comments.UserDisplayName: Anna_MediaGirl
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-22T17:21:21.860Z
Comments.Text: Would that be the case for any field that gets renamed or deleted? It's not an uncommon occurrence during development to add/remove/rename fields as you figure out the best way to organize and build something. I would expect that when renaming a field, the data would not be duplicated, just that the label would change. If not, it seems the admin area should have some way to clean up orphaned data. Is this an oversight or bug?
Comments.UserDisplayName: idahotallpaul
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-08T08:39:10.350Z
Comments.Text: I run in to this regularly, would be a good feature. Maybe a plugin could handle it.
Comments.UserDisplayName: hamishtaplin
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-29T06:21:39.313Z
Comments.Text: It never happened to me that changes to field names didn't make it to the database, and all fields I deleted from the CP were also instantly removed. But I think this is OT in the question anyways, as column handles of a table field must not to be mistaken as field handles.
Comments.UserDisplayName: carlcs
Tags: <templating><table-field>
Title: Is there a way to purge old data in a table?
ThreadText: # Is there a way to purge old data in a table?
  
  (Asked by: username_0 on 2014-08-21)
  
  I have some tables in a matrix field and when I created the columns, originally I named them Col 1, Col 2, etc. That made sense to me but later I decided that since the client will be entering data, it'd make more sense to name them Column 1, Column 2, etc.
  
  I renamed them but that was after I'd entered a bunch of content. So now in the Craft admin, I only see the new names, but when I loop through the entries in the table rows, all of the old entries are there as well.
  
  Is there a way to purge that old data? I want to give the client to enter in the number of a column so you can add a highlight class to it. Right now, as I loop through the entries in those rows, it hits both old and new content and you can't get a dependable count.
  
  **Tags:** templating, table-field
  
  > **Comments:**
  > **username_1**: Sounds like you need to get into the database and do this manually.  
  > **username_0**: Would that be the case for any field that gets renamed or deleted? It's not an uncommon occurrence during development to add/remove/rename fields as you figure out the best way to organize and build something. I would expect that when renaming a field, the data would not be duplicated, just that the label would change. If not, it seems the admin area should have some way to clean up orphaned data. Is this an oversight or bug?  
  > **username_2**: I run in to this regularly, would be a good feature. Maybe a plugin could handle it.  
  > **username_3**: It never happened to me that changes to field names didn't make it to the database, and all fields I deleted from the CP were also instantly removed. But I think this is OT in the question anyways, as column handles of a table field must not to be mistaken as field handles.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2015-07-29. Score: 4 | Accepted answer
  
  Your interpretation of why you're getting duplicate columns when looping your your table field is wrong.
  
  Each column *is always* accessible via a automatically generated column handle (`col1`, `col2`, etc.), so that's not old and left over column names you're seeing there.
  
  If you define custom handles in the Table field's settings, the cells' data will be available via those properties as well, so you can then access the value via both `row.price` and `row.col1`. This feature is designed with direct access of columns / cells in mind, but gets in the way when looping through a row's cells.
  
  But Craft doesn't force you to define custom handles, so you can simply remove them in your field's settings and your "old data" will be removed.
  
  
  ---
  
  