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

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

问题描述

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

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'

我正在使用 ReplaceText 处理器,在该处理器中,我在搜索值"下传递了 \ s 以仅搜索标题行空白和替换值为空字符串.我的评估模式也是逐行".因此现在输出文件显示为 FirstName,LastNameshraddha,srivastavsanstuti,srivastav ,因此它将所有内容显示在一行中.我只希望从标题行中删除空格,并且根本不要触摸/合并数据值.谢谢

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方向正确,但是问题在于文本中的所有空格都将被替换.为了仅替换标题行中的空格,请在Shu的解决方案中进行更改:

@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. 搜索值:

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

  1. 替换价值:

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

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

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