我有一个看起来像如何找出壳列式,并获得差异
emp_id(int),name(string),age(int)
1,hasa,34
2,dafa,45
3,fasa,12
8f,123Rag,12
8,fafl,12
要求的示例文件:列数据类型指定为字符串和整数。 Emp_id应该是一个不是字符串的整数。这些条件对于名称和年龄列是相同的。
我的输出应该像#
Actual column Emp_id type is INT but string was found at the position 4, value is 8f
Actual column name type is STRING but numbers were found at the position 4, value is 123Rag
继续..
这里是我的代码 shell脚本
read input
if [ $input -eq $input 2>/dev/null ]
then
echo "$input is an integer"
else
echo "$input is not an integer"
fi
在Python中,我与Isinstance尝试(OBJ ,类型),但它没有达到目的。 可以在这方面指导我,任何shell/python/perl脚本的帮助将不胜感激!
您的代码与您的要求无关。至少表现出诚实的尝试。 – karakfa
[BASH:测试字符串是否作为一个整数有效吗?]可能的重复(http://stackoverflow.com/questions/2210349/bash-test-whether-string-is-valid-as-an-integer) – tripleee
什么是将数字放入字符串字段的问题? –