我有一个表,其中的列包含数字,一个列在该列中的每个数字之前包含两个字母。
如何删除此列中的这两个字母。
答案 0 :(得分:3)
由于符号仅是对字符串的引用,因此在对基础字符串进行操作之前,需要先对其进行评估。
将drop与每个右运算符一起使用将从列表中删除前2个元素,然后可以将其强制转换为符号格式。
带有列表
q)l:`aa1`bb2
q)string l
"aa1"
"bb2"
q)2_/:string l
,"1"
,"2"
q)`$2_/:string l
`1`2
您可以将其嵌入到更新语句中,用列名替换l。
如果不同符号的数量很少,则可以使用.Q.fu
。这需要一个函数,一次将其应用于每个不同的符号,然后将结果复制到列表的其余部分,这在操作昂贵时会更快,而字符串操作通常是
q)\t .Q.fu[{`$2_/:string x};l]
19
q)\t `$2_/:string l
625
答案 1 :(得分:2)
假设您的表格看起来像这样:
q)t:([]a:1 2 3; b:`aa1`aa2`aa3; c:1 2 3)
q)t
a b c
-------
1 aa1 1
2 aa2 2
3 aa3 3
您可以使用
q)@[t;`b;"F"$2_'string@]
a b c
-----
1 1 1
2 2 2
3 3 3
这会将原始符号转换为字符串,将前2个字符放入b列,然后转换为Float。 您可能希望将它们强制转换为整数,以便执行以下操作:
q)@[t;`b;"I"$2_'string@]
a b c
-----
1 1 1
2 2 2
3 3 3
亲切的问候, 伊斯兰教法
答案 2 :(得分:1)
或在qsql中:
public class lokationRecyclerAdapter extends RecyclerView.Adapter<lokationRecyclerAdapter.RecyclerViewHolder> {
List<String> cardList;
String test;
public lokationRecyclerAdapter(List<String> cardList) {
this.cardList = cardList;
notifyDataSetChanged();
}
@Override
public RecyclerViewHolder onCreateViewHolder(final ViewGroup viewGroup, int i) {
//View view = LayoutInflater.from( viewGroup.getContext() ).inflate( R.layout.lokationcardview, viewGroup, false );
View view = LayoutInflater.from( viewGroup.getContext() ).inflate( R.layout.cardviewnewlokation, viewGroup, false );
return new RecyclerViewHolder( view );
}
public void deleteItem(int position) {
cardList.remove( position );
notifyItemRemoved( position );
notifyItemRangeChanged( position, cardList.size() );
}
@Override
public void onBindViewHolder(RecyclerViewHolder recyclerViewHolder, int position) {
//recyclerViewHolder.cardView.setBackgroundResource( R.drawable.ic_circleshape );
recyclerViewHolder.cardTitle.setText( cardList.get( position ) );
}
@Override
public int getItemCount() {
return cardList.size();
}
class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public int nummer;
private CardView cardView;
private Button menuButton, cardSlet, cardAddLokation;
private TextView lokationsName, cardTitle;
public void alertDialogaddView(final View itemView) {
new AlertDialog.Builder( itemView.getContext() );
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( itemView.getContext() );
builder.setCancelable( true );
builder.setTitle( "Tilføj eller ændre navnet på lokation" );
builder.setMessage( "Hold styr på dine sensorer ved at oprette lokationer i form af eksempelvis lokaler." );
final EditText input = new EditText( itemView.getContext() );
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT );
input.setMaxLines( 1 );
input.setInputType( InputType.TYPE_CLASS_TEXT );
input.setLayoutParams( lp );
builder.setView( input );
builder.setPositiveButton( "Ja", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
test = input.getText().toString();
cardList.add( 0, test );
notifyDataSetChanged();
System.out.println( "CARDLIST: " + cardList );
}
} );
builder.setNegativeButton( "Nej", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
} );
android.support.v7.app.AlertDialog dialog = builder.create();
dialog.show();
}
public void alertDialogsetText(final View itemView) {
new AlertDialog.Builder( itemView.getContext() );
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( itemView.getContext() );
builder.setCancelable( true );
builder.setTitle( "Tilføj eller ændre navnet på lokation" );
builder.setMessage( "Hold styr på dine sensorer ved at oprette lokationer i form af eksempelvis lokaler." );
final EditText input = new EditText( itemView.getContext() );
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT );
input.setMaxLines( 1 );
input.setInputType( InputType.TYPE_CLASS_TEXT );
input.setLayoutParams( lp );
builder.setView( input );
builder.setPositiveButton( "Ja", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
test = input.getText().toString();
cardList.set( getAdapterPosition(), test );
notifyItemChanged( getAdapterPosition() );
}
} );
builder.setNegativeButton( "Nej", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
} );
android.support.v7.app.AlertDialog dialog = builder.create();
dialog.show();
}
public RecyclerViewHolder(final View itemView) {
super( itemView );
//cardView = (CardView) itemView.findViewById( R.id.lokationcard_view );
//menuButton = (Button) itemView.findViewById( R.id.menuButton );
//lokationsName = (TextView) itemView.findViewById( R.id.lokationsName );
lokationsName = (Button) itemView.findViewById( R.id.cardNavn );
cardTitle = (TextView) itemView.findViewById( R.id.cardTitle );
cardSlet = (Button) itemView.findViewById( R.id.cardSlet );
cardAddLokation = (Button) itemView.findViewById( R.id.cardAddLokation );
itemView.setOnClickListener( this );
lokationsName.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!cardList.get( getAdapterPosition() ).equals( "TILFØJ LOKATION" )) {
alertDialogsetText( itemView );
} else {
Toast.makeText( itemView.getContext(), "KAN IKKE ÆNDRE SIDSTE CARDVIEW", Toast.LENGTH_LONG ).show();
}
}
} );
cardSlet.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!cardList.get( getAdapterPosition() ).equals( "TILFØJ LOKATION" )) {
deleteItem( getAdapterPosition() );
} else {
Toast.makeText( itemView.getContext(), "KAN IKKE SLETTE SIDSTE CARDVIEW", Toast.LENGTH_LONG ).show();
}
}
} );
cardAddLokation.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
alertDialogaddView( itemView );
System.out.println("DET VIRKER JUHUU!!!" + cardList);
}
} );
}
}
}
如果b不是符号,而是一个字符列表,则可以删除对
的调用