# columns get mixed up when creating bar chart or group by

**URL:** <https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882>\
**Category:** Node Development\
**Created:** [December 12, 2018, 11:30pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882 "2018-12-12T23:30:37Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 12, 2018, 11:30pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/1 "2018-12-12T23:30:37Z")

</div>

I imported a csv file and all the columns look fine in the file reader (have to use allow short line for it to be read correctly). However, when I create a bar chart or use groupby note, the columns get mixed up. For example, gender column only has male and female and NA values, but for some reason, the bar chart reads data from another column named hair color.

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/f/f0f20581d85d54c0bcd424a5acccc400a967c641.png)

![image](https://forum-cdn.knime.com/uploads/default/original/2X/e/e0deae3d472fdaba3bf07db175ae4b984c4b1fdb.png)

---

<div class="post-metadata">

**Author:** ![daria.goldmann](https://forum-cdn.knime.com/user_avatar/forum.knime.com/daria.goldmann/32/418_2.png) [@daria.goldmann](https://forum.knime.com/u/daria.goldmann)\
**Post date:** [December 14, 2018, 6:02pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/2 "2018-12-14T18:02:50Z")

</div>

Hi Learn2019,

What are the settings you are using in the configuration of the Bar Chart (JavaScript) node?  
And what would you like to see as a result?

Kind regards,  
Daria

---

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 15, 2018, 12:44am UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/3 "2018-12-15T00:44:10Z")

</div>

Daria,

Here is the configuration. I just need to see a bar chart with only three values. Male, Female and NA.

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/f/f3f4612ca67b3ea6f54ed93c7dc46ae40ee0eac0.png)

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [December 15, 2018, 11:23am UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/4 "2018-12-15T11:23:57Z")

</div>

Are you able to share the data and the workflow? If you are we might take a look. These things come to mind:

- i would recommend doing a group by on the columns in question to see if they really do not contain the unwanted data (if they do the problem is with the import)
- you mentioned you had to use “short line” to import the data. CSV files can be tricky i a separating character also appears in the data itself. KNIME sometimes is seemingly not so great in handling that.
- from the screenshot there seem to be quotes and maybe even cascaded quotes in your data, this could easily mess up the columns on import
- you could try doing the import with the R package Readr \*1) or you could try the File Reader of KNIME instead of the CSV reader \*2) - they give you more control about how to import data
- if you can get the data via a more stable format then CSV you might want to use that

\*1)

> [@Error with File Reader node while running in a loop](https://forum.knime.com/t/error-with-file-reader-node-while-running-in-a-loop/11263/3):
>
> I had a similar problem where there were some ‘dirty’ CSV files out of a large number of files and they were too large to just ‘edit’ them in Notepad++ (and that also was not a very nice process). I built a workflow using the R package readr, which seems to me more tolerant towards problematic CSV files and gives you some control how to handle mismatching quotes and so on. You might have to toy around with the settings of the read\_delim function. [kn\_example\_import\_csv\_r\_readr.knwf](https://forum-cdn.knime.com/uploads/default/original/2X/b/be919d2124e542ced4cae1a0d52304e7fd06b9b6.knwf) (52.…

\*2) [KNIME Learning Center | KNIME](https://www.knime.com/knime-introductory-course/chapter2/section1/file-reader-node)

---

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 17, 2018, 4:58pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/5 "2018-12-17T16:58:39Z")

</div>

mlauber71,

Thank you very much for your help It is definitely the problem with importing. I looked at it more carefully and it seems that several rows are not imported correctly. I used File reader node but it did not solve the problem. I am new to KNIME. I tried R source node but I am not sure how to make it work. I will continue working on it and post a reply when I solve it.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [December 17, 2018, 5:11pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/6 "2018-12-17T17:11:48Z")

</div>

If you are able to upload the data or a sample that shows the potential problems we would be able to have a look. I would recommend trying to use the R package or get the data in a more ‘stable’ format. Like using a more exotic separator like “|” or even “¤” (Ascii 207) - we used to call this the “run over turtle” and it is very uncommon though still an ascii sign.

---

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 17, 2018, 6:21pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/7 "2018-12-17T18:21:33Z")

</div>

Thank you! Here is the link:

[https://drive.google.com/file/d/1\_csuYvyT1daXAJZqFxelRDcrr1u2l5TW/view](https://drive.google.com/file/d/1_csuYvyT1daXAJZqFxelRDcrr1u2l5TW/view)

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [December 17, 2018, 8:50pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/8 "2018-12-17T20:50:09Z")

</div>

with the help of R’s Readr I was able to load the data and now it seems there is no mixup in the data. Although some columns need serious work if you want to use them like first\_appear which is a strange mixture of dates and some missing.

You should analyse the data with group bys and check some plausibility because also with Readr there is no guarantee it caught all the quirks. It looks like a mixture of several data bases with slightly different structures. You might want to check them.

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/0/09f67afa65d5ba9c997001c8969cab5d0b2da773.png)

Things like these form of quote very likely drives a KNIME node mad 🙂

![image](https://forum-cdn.knime.com/uploads/default/original/2X/c/c64ff9bd1a74823fad3109e88ef98a0d854d2122.png)

![image](https://forum-cdn.knime.com/uploads/default/original/2X/2/2df20eb04380d394d6c2665c011c4de96e22d994.png)

[kn\_example\_comic.knar](https://forum-cdn.knime.com/uploads/default/original/2X/6/6128dc6454efa75c687b3d3cf9d4d652ae71a039.knar) (2.2 MB)

---

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 17, 2018, 9:35pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/9 "2018-12-17T21:35:44Z")

</div>

Thank you so much! Much appreciated.

---

<div class="post-metadata">

**Author:** ![daria.goldmann](https://forum-cdn.knime.com/user_avatar/forum.knime.com/daria.goldmann/32/418_2.png) [@daria.goldmann](https://forum.knime.com/u/daria.goldmann)\
**Post date:** [December 20, 2018, 10:33am UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/10 "2018-12-20T10:33:55Z")

</div>

You could use the Line Reader node to just read the file line by line. Connect it to the Cell Splitter node to split the file using specified delimiter. Both nodes allow to keep the Column headers, so you won’t lose this information. Then you could filter unwanted Rows and Columns, e.g. those with missing values, using the respective filter nodes.

Best,  
Daria

---

<div class="post-metadata">

**Author:** ![Learn2019](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@Learn2019](https://forum.knime.com/u/Learn2019)\
**Post date:** [December 20, 2018, 9:36pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/11 "2018-12-20T21:36:36Z")

</div>

Thank you!!! This is very helpful.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [December 20, 2018, 9:59pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/12 "2018-12-20T21:59:16Z")

</div>

\<smartypants mode\>  
The problem is you would loose the information when you might just as well have kept it. And in this specific dataset with just the split by “,” you will get a systematic shift further down the line because of the strange  
, “1940, June”, dc  
construct.  
\</smartypants mode\>

 ![image](https://forum-cdn.knime.com/uploads/default/original/2X/6/6c9082d6c2c6f8e0e58b844fba4d19f58dc5b3fb.png)

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:31pm UTC](https://forum.knime.com/t/columns-get-mixed-up-when-creating-bar-chart-or-group-by/12882/13 "2023-06-23T20:31:52Z")

</div>


