是否可以从 NiFi 中的 CSV 文件标题名称中删除空格? [英] Is it possible to remove white spaces from the CSV files header name in NiFi?

查看:27
本文介绍了是否可以从 NiFi 中的 CSV 文件标题名称中删除空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CSV 文件,其中某些列名中有空格,而某些列名在字符之间没有空格.我想从所有包含空格的标题名称中删除空格.请帮忙.谢谢!

附上截图以供参考.示例:'名字'我想要'名字'

我正在使用 ReplaceText 处理器,其中在搜索值下,我通过 \s 仅搜索标题行空格和替换值作为空字符串.另外我的评估模式是逐行".所以现在输出文件显示为 FirstName,LastNameshraddha,srivastavsanstuti,srivastav 所以它在一行中显示所有内容.我只想从标题行中删除空格,并且根本不触摸/合并数据值.谢谢

请告诉我如何删除它们.谢谢!

解决方案

@Shu 方向正确,但问题是文本中的所有空格都会被替换.为了仅替换标题行中的空格,在 Shu 的解决方案中更改:

  1. 搜索值:

<块引用>

(?s)(^[^\n]*)(.*$)

  1. 替换值:

<块引用>

${'$1':replace(" ","")}$2

I have a CSV file in which some column name have white spaces in it and some column names are without the white space between characters. I want to remove the white spaces from all the header names that has white space in it. Please help. Thank you!

Attaching screenshot for reference. Example: 'First Name' I want 'FirstName'

I am using ReplaceText processor in which under Search value I have passes \s to search just the header row white spaces and replacement value as Empty string. Also my evaluation mode is 'Line-by-Line'. so now the ouput file is showing as FirstName,LastNameshraddha,srivastavsanstuti,srivastav So it's showing everything in one line. I want white spaces only to be removed from header row and do not touch/merge the data values at all.Thanks

Please tell me how to remove them. Thank you!

解决方案

@Shu is on the right direction, but the problem is that all spaces in the text will be replaced. In order to replace spaces ONLY in header row, in Shu's solution change:

  1. Search Value:

(?s)(^[^\n]*)(.*$)

  1. Replacement Value:

${'$1':replace(" ","")}$2

这篇关于是否可以从 NiFi 中的 CSV 文件标题名称中删除空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆